output

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta

type Meta struct {
	// Date represents time when output was generated.
	Date time.Time `json:"date"`
	// FinderVersion the version of gnfinder
	FinderVersion string `json:"gnfinderVersion"`
	// WithBayes use of bayes during name-finding
	WithBayes bool `json:"withBayes"`
	// TokensAround shows number of tokens preserved before and after
	// a name-string candidate.
	TokensAround int `json:"tokensAround"`
	// Language inside name-finding algorithm
	Language string `json:"language"`
	// LanguageDetected automatically for the text
	LanguageDetected string `json:"languageDetected,omitempty"`
	// LanguageForced by language option
	DetectLanguage bool `json:"detectLanguage"`
	// TotalTokens is a number of 'normalized' words in the text
	TotalTokens int `json:"totalWords"`
	// TotalNameCandidates is a number of words that might be a start of
	// a scientific name
	TotalNameCandidates int `json:"totalCandidates"`
	// TotalNames is a number of scientific names found
	TotalNames int `json:"totalNames"`
	// CurrentName (optional) is the index of the names array that designates a
	// "position of a cursor". It is used by programs like gntagger that allow
	// to work on the list of found names interactively.
	CurrentName int `json:"currentIndex,omitempty"`
}

Meta contains meta-information of name-finding result.

type Name

type Name struct {
	// Cardinality depicts number of elements in a name. 0 - Cannot determine
	// cardinality, 1 - Uninomial, 2 - Binomial, 3 - Trinomial.
	Cardinality int `json:"cardinality"`
	// Verbatim shows name the way it was in the text.
	Verbatim string `json:"verbatim"`
	// Name is a normalized version of a name.
	Name string `json:"name"`
	// Odds show a probability that name detection was correct.
	Odds float64 `json:"odds,omitempty"`
	// OddsDetails desrive how Odds were calculated.
	OddsDetails token.OddsDetails `json:"oddsDetails,omitempty"`
	// OffsetStart is a start of a name on a page.
	OffsetStart int `json:"start"`
	// OffsetEnd is the end of the name on a page.
	OffsetEnd int `json:"end"`
	// AnnotNomen is a nomenclatural annotation for new species or combination.
	AnnotNomen string `json:"annotationNomen,omitempty"`
	// AnnotNomenType is normalized nomenclatural annotation.
	AnnotNomenType string `json:"annotationNomenType,omitempty"`
	// Annotation is a placeholder to add more information about name.
	Annotation string `json:"annotation"`
	// WordsBefore are words that happened before the name.
	WordsBefore []string `json:"wordsBefore,omitempty"`
	// WordsAfter are words that happened right after the name.
	WordsAfter []string `json:"wordsAfter,omitempty"`
	// Verification gives results of verification process of the name.
	Verification *verifier.Verification `json:"verification,omitempty"`
}

Name represents one found name.

type OddsDatum

type OddsDatum struct {
	Name bool
	Odds float64
}

OddsDatum is a simplified version of a name, that stores boolean decision (Name/NotName), and corresponding odds of the name.

type Option added in v0.11.0

type Option func(*Output)

Options type for modifying settings for the Output

func OptLanguage added in v0.11.0

func OptLanguage(l string) Option

OptLanguage sets a string representation of a language

func OptLanguageDetected added in v0.11.0

func OptLanguageDetected(ld string) Option

OptLanguageDetected sets LanguageDetected field

func OptTokensAround added in v0.11.0

func OptTokensAround(t int) Option

OptTokensAround sets configuration for how many tokens should surround a found name.

func OptVersion added in v0.11.0

func OptVersion(v string) Option

OptVersion sets gnfinder version to the output.

func OptWithBayes added in v0.11.0

func OptWithBayes(b bool) Option

OptWithBayes sets WithBayes field

type Output

type Output struct {
	Meta  `json:"metadata"`
	Names []Name `json:"names"`
}

Output type is the result of name-finding.

func TokensToOutput

func TokensToOutput(ts []token.Token, text []rune, tokensAround int,
	oddsDetails bool, opts ...Option) *Output

TokensToOutput takes tagged tokens and assembles output out of them.

func (*Output) FromJSON

func (o *Output) FromJSON(data []byte)

FromJSON converts JSON representation of Outout to Output object.

func (*Output) MergeVerification

func (o *Output) MergeVerification(v verifier.Output)

MergeVerification takes a map with verified names and incorporates into output.

func (*Output) ToJSON

func (o *Output) ToJSON() []byte

ToJSON converts Output to JSON representation.

func (*Output) UniqueNameStrings

func (o *Output) UniqueNameStrings() []string

UniqueNameStrings takes a list of names, and returns a list of unique name-strings

Jump to

Keyboard shortcuts

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