matcher

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 2 Imported by: 0

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 FuzzyMatcher

type FuzzyMatcher interface {
	// MatchStem takes a stemmed scientific name and max edit distance.
	// The search stops if current edit distance becomes bigger than edit
	// distance. The method returns 0 or more stems that did match the
	// input stem within the edit distance constraint.
	MatchStem(stem string, maxEditDistance int) []string
	// StemToCanonicals takes a stem and returns back canonicals
	// that correspond to that stem.
	StemToMatchItems(stem string) []MatchItem
}

FuzzyMatcher describes methods needed for fuzzy matching

type Match

type Match struct {
	// ID is UUIDv5 generated from verbatim input name-string.
	ID string
	// Name is verbatim input name-string.
	Name string
	// VirusMatch is true if matching
	VirusMatch bool
	// MatchType describe what kind of match happened.
	MatchType vlib.MatchType
	// MatchItems provide all matched data. It will be empty if no matches
	// occured.
	MatchItems []MatchItem
}

Match is output of MatchAry method.

type MatchItem

type MatchItem struct {
	// ID is a UUIDv5 generated out of MatchStr.
	ID string
	// 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
	// EditDistance is a Levenshtein edit distance between normalized
	// input and MatchStr.
	EditDistance int
	// EditDistanceStem is a Levenshtein edit distance between stemmed input and
	// stemmed MatchStr.
	EditDistanceStem int
}

MatchItem describes one matched string and its properties.

type Matcher

type Matcher interface {
	// Versioner interface gets version of a project
	gn.Versioner

	// MatchAry takes a list of strings and matches each of them
	// to known scientific names.
	MatchAry(names []string) []*Match
}

Matcher describes methods required for matching name-strings to names.

Jump to

Keyboard shortcuts

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