corpus

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagLicenseText      uint16 = 1 << 1
	FlagLicenseNotice    uint16 = 1 << 2
	FlagLicenseTag       uint16 = 1 << 3
	FlagLicenseReference uint16 = 1 << 4
	FlagLicenseIntro     uint16 = 1 << 5
	FlagLicenseClue      uint16 = 1 << 6
	FlagFalsePositive    uint16 = 1 << 7
	FlagRequiredPhrase   uint16 = 1 << 8
	FlagContinuous       uint16 = 1 << 9
	FlagDeprecated       uint16 = 1 << 10
)
View Source
const FormatVersion = 7

FormatVersion is the on-disk corpus index format.

Variables

This section is empty.

Functions

func EmbeddedSize

func EmbeddedSize() int

EmbeddedSize returns the compressed corpus size in bytes.

func Write

func Write(w io.Writer, index Index) error

Write encodes index as a deterministic gzip-compressed binary stream.

Types

type Index

type Index struct {
	Info        Info
	Vocabulary  []string
	StopwordIDs []uint32
	Rules       []Rule
	Automaton   aho.Automaton
	// SPDXKeys maps lowercase SPDX identifiers, and their deprecated aliases,
	// to ScanCode license keys.
	SPDXKeys map[string]string
	// ReportingIDs maps ScanCode license keys to their canonical SPDX
	// identifier or LicenseRef-scancode-* value.
	ReportingIDs map[string]string
}

Index is a decoded corpus.

func Load

func Load() (Index, error)

Load reads the embedded corpus.

func Read

func Read(r io.Reader) (Index, error)

Read decodes a corpus index and checks its framing and limits.

type Info

type Info struct {
	Version      string
	RuleCount    int
	SourceCommit string
}

Info identifies the source and contents of an index.

type Rule

type Rule struct {
	ID            string
	Expression    string
	Text          []byte
	Tokens        []uint32
	StopwordAfter []uint32
	Flags         uint16
	Relevance     uint8
}

Rule is the source data needed to build the matching indexes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL