common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitIfError

func ExitIfError(prefix string, err error)

ExitIfError exits a program with a fatal error message, if // the supplied error is not nil.

func FileOrStdin

func FileOrStdin(args []string, idx int) *os.File

FileOrStdin opens the file at the given index for reading when the index is valid. Otherwise, it returns os.Stdin.

func FileOrStdout

func FileOrStdout(args []string, idx int) *os.File

FileOrStdout opens the file at the given index for writing when the index is valid. Otherwise, it returns os.Stdout.

func MustLoadClosedClass

func MustLoadClosedClass(filename string) model.ClosedClassSet

func MustLoadSubstitutions

func MustLoadSubstitutions(filename string) []words.Substitution

Types

type CitarConfig

type CitarConfig struct {
	Model          string
	Substitutions  string
	UnknownHandler string `toml:"unknown_handler"`
}

CitarConfig stores the configuration of citar.

func MustParseConfig

func MustParseConfig(filename string) *CitarConfig

MustParseConfig parses the given configuration file. If the file could not be parsed successfully, the process is exited with an error message.

func ParseConfig

func ParseConfig(reader io.Reader) (*CitarConfig, error)

ParseConfig attempts to parse the configuration from the given reader.

func (CitarConfig) UnknownWordHandler

func (c CitarConfig) UnknownWordHandler(m model.Model) (words.WordHandler, error)

UnknownWordHandler returns a word handler given the tagger configuration and a data model.

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

The Evaluator type is used to keep counts on the number of correctly/incorrectly tagged known/unknown tokens.

func NewEvaluator

func NewEvaluator(tagger tagger.HMMTagger, model model.Model) *Evaluator

NewEvaluator creates an evaluator that uses the provided tagger and the corresponding model. The model is used to distinguish known and unknown tokens.

func (*Evaluator) Accuracy

func (e *Evaluator) Accuracy() float64

Accuracy returns the tagging accuracy.

func (*Evaluator) KnownAccuracy

func (e *Evaluator) KnownAccuracy() float64

KnownAccuracy returns the tagging accuracy of known words.

func (*Evaluator) KnownCorrect

func (e *Evaluator) KnownCorrect() uint

KnownCorrect returns the number of correctly tagged known words.

func (*Evaluator) KnownIncorrect

func (e *Evaluator) KnownIncorrect() uint

KnownIncorrect returns the number of incorrectly tagged known words.

func (*Evaluator) OverallCorrect

func (e *Evaluator) OverallCorrect() uint

OverallCorrect returns the number of correctly tagged words.

func (*Evaluator) OverallIncorrect

func (e *Evaluator) OverallIncorrect() uint

OverallIncorrect returns the number of incorrectly tagged words.

func (*Evaluator) Process

func (e *Evaluator) Process(sent []conllx.Token) error

Process a sentence, tagging it using the Evaluator's tagger and counting the number of tokens that were tagged correctly.

func (*Evaluator) UnknownAccuracy

func (e *Evaluator) UnknownAccuracy() float64

UnknownAccuracy returns the tagging accuracy of unknown words.

func (*Evaluator) UnknownCorrect

func (e *Evaluator) UnknownCorrect() uint

UnknownCorrect returns the number of correctly tagged unknown words.

func (*Evaluator) UnknownIncorrect

func (e *Evaluator) UnknownIncorrect() uint

UnknownIncorrect returns the number of incorrectly tagged unknown words.

Jump to

Keyboard shortcuts

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