verifier

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const GNindexURL = "http://index.globalnames.org/api/graphql"

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchResult added in v0.8.4

type BatchResult struct {
	Names    []string
	Response *graphqlResponse
	Retries  int
	Error    error
}

type NameInput

type NameInput struct {
	Value string `json:"value"`
}

type Option added in v0.8.4

type Option func(*Verifier)

Option type for changing Verifier.

func OptBatchSize added in v0.8.4

func OptBatchSize(n int) Option

OptBatchSize sets the batch size of name-strings to send to the verification service.

func OptSources added in v0.8.4

func OptSources(s []int) Option

OptSources is an option that sets IDs of data sources used for verification. Results from these sources (if any) will be returned no matter what is the best matching result.

func OptURL added in v0.8.4

func OptURL(url string) Option

OptURL option sets a new url for name verification service.

func OptWorkers added in v0.8.4

func OptWorkers(n int) Option

OptWorkers option sets the number of workers to process name-verification jobs.

type Output added in v0.8.4

type Output map[string]*Verification

type ResultData added in v0.8.8

type ResultData struct {
	// DataSourceID is the ID of the DataSource of the returned best match result.
	DataSourceID int `json:"dataSourceId,omitempty"`
	// DataSourceTitle is the Title of the DataSource of the returned best match result.
	DataSourceTitle string `json:"dataSourceTitle,omitempty"`
	// TaxonID identifier of a taxon
	TaxonID string `json:"taxonId,omitempty"`
	// MatchedName is a verbatim name-string from the matched result.
	MatchedName string `json:"matchedName,omitempty"`
	// MatchedCardinality is a number of elements in a name. 0 - no name at all,
	// 1 - Uninomial, 2 - Binomial, 3 - Trinomial
	MatchedCardinality int `json:"matchedCardinality,omitempty"`
	// MatchedCanonical is a canonical form of a matched name
	MatchedCanonicalSimple string `json:"matchedCanonicalSimple,omitempty"`
	// MatchedCanonicalFull is a canonical form of a matched name with ranks
	// and a hybrid sign for named hybrids
	MatchedCanonicalFull string `json:"matchedCanonicalFull,omitempty"`
	// CurrentName is a currently accepted name according to the matched result.
	CurrentName string `json:"currentName,omitempty"`
	// CurrentCardinality is a number of elements in a name. 0 - no name at all,
	// 1 - Uninomial, 2 - Binomial, 3 - Trinomial
	CurrentCardinality int `json:"currentCardinality,omitempty"`
	// CurrentCanonical is a canonical form of a current name
	CurrentCanonicalSimple string `json:"currentCanonicalSimple,omitempty"`
	// CurrentCanonicalFull is a canonical form of a current name with ranks
	// and a hybrid sign for named hybrids
	CurrentCanonicalFull string `json:"currentCanonicalFull,omitempty"`
	// CurrentName is a currently accepted name according to the matched result.
	// Synonym is true when the name is not the same as currently accepted.
	Synonym bool `json:"isSynonym,omitempty"`
	// ClassificationPath of the matched result.
	ClassificationPath string `json:"classificationPath,omitempty"`
	// ClassificationRank of the matched result.
	ClassificationRank string `json:"classificationRank,omitempty"`
	// ClassificationIDs of the matched result.
	ClassificationIDs string `json:"classificationIds,omitempty"`
	// EditDistance tells how many changes needs to be done to apply fuzzy
	// match to requested name.
	EditDistance int `json:"editDistance,omitempty"`
	// StemEditDistance tells how many changes needs to be done to apply fuzzy
	// match to stemmed name.
	StemEditDistance int `json:"stemEditDistance,omitempty"`
	// MatchType tells what kind of verification occurred if any.
	MatchType string `json:"matchType,omitempty"`
}

type Verification

type Verification struct {
	// BestResult returns a result with the best overal score.
	BestResult *ResultData `json:"bestResult"`
	// PreferredResults contains verification for data sources the user needs
	// to be present if available.
	PreferredResults []*ResultData `json:"preferredResults,omitempty"`
	// DataSourcesNum tells how many databases matched by the name-string.
	DataSourcesNum int `json:"dataSourcesNum,omitempty"`
	// DataSourceQuality shows if a name-string was found in curated or
	// auto-curated data sources.
	DataSourceQuality string `json:"dataSourceQuality,omitempty"`
	// Retries is number of attempted retries.
	Retries int `json:"retries,omitempty"`
	// ErrorString explains what happened if resolution did not work.
	Error string `json:"error,omitempty"`
}

Verification presents data of an attempted remote verification of a name-string.

type Verifier added in v0.8.4

type Verifier struct {
	// URL of name-verification service.
	URL string
	// BatchSize of a name-strings' slice sent for verification.
	BatchSize int
	// Workers is a number of workers that send batches of name strings to
	// verification service.
	Workers int
	// WaitTimeout defines how long to wait for a response from
	// verification service.
	WaitTimeout time.Duration
	// Sources is a slice of Data Source IDs. Results from these
	// Data Sources will always be provided unless they are empty.
	Sources []int
}

Verifier is responsible for estimating validity of found name-strings.

func NewVerifier added in v0.8.4

func NewVerifier(opts ...Option) *Verifier

func (*Verifier) Run added in v0.8.4

func (v *Verifier) Run(names []string) Output

Jump to

Keyboard shortcuts

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