matcher

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Package matcher provides main data-structures that describe input and

output of gnmatcher functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input added in v0.13.4

type Input struct {
	// Names is a slice of name-strings.
	Names []string `json:"names"`

	// WithSpeciesGroup -- when true, species are searched within species group.
	// It means that autonyms in botany and coordination names in zoology.
	WithSpeciesGroup bool `json:"withSpeciesGroup,omitempty"`

	// WithRelaxedFuzzyMatch -- when true, the fuzzy matching is relaxed.
	// Maximum edit distance is increased from 1 to 2, there are no constraints
	// on the length of the strings to be matched.
	WithRelaxedFuzzyMatch bool `json:"withRelaxedFuzzyMatch,omitempty"`

	// WithUninomialFuzzyMatch -- when true, the uninomials go through
	// fuzzy matching together with bi- and tri-nomials.
	WithUninomialFuzzyMatch bool `json:"withUninomialFuzzyMatch,omitempty"`

	// DataSources -- is a list of data-sources that are used to search
	// a for a name-string
	DataSources []int `json:"dataSources,omitempty"`
}

Input for the matcher includes a slice of name-strings several options sent to the matcher.

type Match

type Match struct {
	// ID is a UUIDv5 string generated from `Name` field.
	ID string `json:"id"`

	// Name is a verbatim name-string from `Input.Names`.
	Name string `json:"input"`

	// MatchType describe what kind of match happened.
	MatchType vlib.MatchTypeValue `json:"matchType"`

	// MatchItems provide all matched data. It will be empty if no matches
	// occured.
	MatchItems []MatchItem `json:"matchItems,omitempty"`
}

Match represents match results for one name-string.

type MatchItem

type MatchItem struct {
	// ID is a UUIDv5 generated out of MatchStr.
	ID string `json:"id"`

	// InputStr is the string used for matching. Usually it is the canonical
	// form of the input name. However, if matching was partial, it is
	// the string that was created by partial matching algorithm.
	InputStr string `json:"inputString"`

	// MatchStr is the string that matched a particular input. More often than
	// not it is a canonical form of a name. However for viruses it
	// can be matched string from the database.
	MatchStr string `json:"matchString"`

	// MatchType describe what kind of match happened.
	MatchType vlib.MatchTypeValue `json:"matchType"`

	// EditDistance is a Levenshtein edit distance between
	// InputStr and MatchStr.
	EditDistance int `json:"editDistance"`

	// EditDistanceStem is a Levenshtein edit distance between stemmed
	// InputStr and stemmed MatchStr.
	EditDistanceStem int `json:"editDistanceStem"`

	// DataSourcesMap is a set of data-sources that have this particular
	// MatchItem.
	DataSourcesMap map[int]struct{} `json:"-"`

	// DataSources is an array of data-sources that have this particular
	// MatchItem
	DataSources []int `json:"dataSources,omitempty"`
}

MatchItem describes one matched string and its properties.

type Meta added in v0.14.0

type Meta struct {
	// NamesNum is the number of name-strings sent for matching.
	NamesNum int `json:"namesNum"`

	// WithSpeciesGroup is set to the value of the `Input`'s option
	// `WithSpeciesGroup`.
	WithSpeciesGroup bool `json:"withSpeciesGroup,omitempty"`

	// WithRelaxedFuzzyMatch is set to the value of the `Input`'s option
	// `WithRelaxedFuzzyMatch`. When true, the fuzzy matching rules are relaxed.
	// It provides more matches, but they are less accurate.
	WithRelaxedFuzzyMatch bool `json:"withRelaxedFuzzyMatch,omitempty"`

	// WithUninomialFuzzyMatch is true when fuzzy matching of
	// uninomials was allowed. It is set to the value of the
	// `Input`'s option `WithUninomialFuzzyMatch`.
	WithUninomialFuzzyMatch bool `json:"withUninomialFuzzyMatch,omitempty"`

	// DataSources is set to the value of the `Input`'s option
	// 'WithSpeciesGroup'.
	DataSources []int `json:"dataSources,omitempty"`
}

Meta contains metadata about the matching request.

type Output added in v0.13.4

type Output struct {
	// Meta is the metadata of the request results.
	Meta `json:"metadata"`
	// Matches contains results of name-matching.
	Matches []Match `json:"matches"`
}

Jump to

Keyboard shortcuts

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