Documentation ΒΆ
Index ΒΆ
- Constants
- Variables
- type Algorithm
- type Database
- func (db *Database) AlgorithmCount() int
- func (db *Database) Contains(algorithmName, licenseName string) bool
- func (db *Database) Entries(algorithmName string) []*License
- func (db *Database) Entry(algoirthmName, licenseName string) *License
- func (db *Database) LicenseCount() int
- func (db *Database) Merge(other *Database) *Database
- func (db *Database) Put(algorithmName string, license *License)
- func (db *Database) Write(writer io.Writer) error
- func (db *Database) WriteTo(destFile string) error
- type DatabaseType
- type Identifier
- type License
- type LicenseFile
- type Project
- type Result
- type Time
Constants ΒΆ
const DatabasePathEnvName = "LIOSS_DBPATH"
Variables ΒΆ
var AvailableAlgorithms = []string{"1gram", "2gram", "3gram", "4gram", "5gram", "6gram", "7gram", "8gram", "9gram", "wordfreq", "tfidf"}
AvailableAlgorithms contains the names of available algorithm for comparing licenses.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Algorithm ΒΆ
type Algorithm interface { Prepare(db *Database) error Parse(reader io.Reader, licenseName string) (*License, error) Compare(license1, license2 *License) float64 String() string }
Algorithm shows an algorithm for identifying the license.
func NewAlgorithm ΒΆ
NewAlgorithm create an instance of Algorithm. Available values are [1-9]gram, and tfidf.
type Database ΒΆ
type Database struct { Timestamp *Time `json:"create-at"` Data map[string][]*License `json:"algorithms"` }
Database represents the database for the lioss.
func LoadDatabase ΒΆ
func LoadDatabase(databaseTypes DatabaseType) (*Database, error)
LoadDatabase loads the lioss database from system path. This function search the following directories.
* ENV['LIOSS_DBPATH'] * /usr/local/opt/lioss/data * /opt/lioss/data * ./data
If the directory found, this function loads the Base.liossgz, OSIApproved.liossgz, and Deprecated.liossgz as needed.
func NewDatabase ΒΆ
func NewDatabase() *Database
NewDatabase create an instance of database for lioss.
func ReadDatabase ΒΆ
ReadDatabase reads database from given path.
func (*Database) AlgorithmCount ΒΆ
func (*Database) Entry ΒΆ
Entry return an instance of license built by given algorithm with given license name.
func (*Database) LicenseCount ΒΆ
type DatabaseType ΒΆ
type DatabaseType int
const ( OSI_APPROVED_DATABASE DatabaseType = 1 DEPRECATED_DATABASE DatabaseType = 2 OSI_DEPRECATED_DATABASE DatabaseType = 4 NONE_OSI_APPROVED_DATABASE DatabaseType = 8 WHOLE_DATABASE DatabaseType = OSI_APPROVED_DATABASE | DEPRECATED_DATABASE | OSI_DEPRECATED_DATABASE | NONE_OSI_APPROVED_DATABASE )
func (DatabaseType) IsType ΒΆ
func (dt DatabaseType) IsType(dbType DatabaseType) bool
func (DatabaseType) String ΒΆ
func (dt DatabaseType) String() string
type Identifier ΒΆ
Identifier is a type for identifying the license.
func NewIdentifier ΒΆ
func NewIdentifier(algorithmName string, threshold float64, db *Database) (*Identifier, error)
NewIdentifier creates an instance of Identifier with the given arguments. The range of threshold must be from 0.0 to 1.0.
func (*Identifier) Identify ΒΆ
func (identifier *Identifier) Identify(project Project) (map[LicenseFile][]*Result, error)
Identify identifies the license of the given project.
type License ΒΆ
type License struct { Name string `json:"license-name"` Frequencies map[string]int `json:"frequencies"` }
License shows the license data for identifying.
type LicenseFile ΒΆ
type LicenseFile interface { ID() string Read(p []byte) (int, error) Close() error String() string }
LicenseFile shows the path of license in the project.
type Project ΒΆ
type Project interface { /* BasePath returns the project path. */ BasePath() string /* Close closes the project, and after call this method, this project is not available. */ Close() error /* LicenseIDs returns the ids for licenses in the project. */ LicenseIDs() []string /* LicenseFile returns the path of the License files in the project. */ LicenseFile(licenseID string) (LicenseFile, error) }
Project shows project containing some licenses.
func NewProject ΒΆ
NewProject creates an instance of Project. Acceptable file formats of this function is zip/jar/war file, and directory.
type Result ΒΆ
type Result struct { /*Name shows the license name.*/ Name string /*Probability represents the probability of the license, by range of 0.0 to 1.0.*/ Probability float64 }
Result shows identified license and its probability.
type Time ΒΆ
type Time struct {
// contains filtered or unexported fields
}
Time represents the time for marshaling a specific format.
func (*Time) MarshalJSON ΒΆ
MarshalJSON is called on marshaling JSON.
func (*Time) UnmarshalJSON ΒΆ
UnmarshalJSON is called on unmarshaling JSON.