Documentation
¶
Overview ¶
Package tag implements functions for tagging parts of speech.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AveragedPerceptron ¶
type AveragedPerceptron struct {
// contains filtered or unexported fields
}
AveragedPerceptron is a Averaged Perceptron classifier.
func NewAveragedPerceptron ¶
func NewAveragedPerceptron(weights map[string]map[string]float64, tags map[string]string, classes []string) *AveragedPerceptron
NewAveragedPerceptron creates a new AveragedPerceptron model.
type PerceptronTagger ¶
type PerceptronTagger struct {
// contains filtered or unexported fields
}
PerceptronTagger is a port of Textblob's "fast and accurate" POS tagger. See https://github.com/sloria/textblob-aptagger for details.
func NewPerceptronTagger ¶
func NewPerceptronTagger() *PerceptronTagger
NewPerceptronTagger creates a new PerceptronTagger and loads the built-in AveragedPerceptron model.
func NewTrainedPerceptronTagger ¶
func NewTrainedPerceptronTagger(model *AveragedPerceptron) *PerceptronTagger
NewTrainedPerceptronTagger creates a new PerceptronTagger using the given model.
func (*PerceptronTagger) Classes ¶
func (pt *PerceptronTagger) Classes() []string
Classes returns the model's classes in the form
["EX", "NNPS", "WP$", ...]
func (*PerceptronTagger) Tag ¶
func (pt *PerceptronTagger) Tag(words []string) []Token
Tag takes a slice of words and returns a slice of tagged tokens.
func (*PerceptronTagger) TagMap ¶
func (pt *PerceptronTagger) TagMap() map[string]string
TagMap returns the model's classes in the form
{ "four": "CD", "facilities": "NNS", ... }
func (*PerceptronTagger) Train ¶
func (pt *PerceptronTagger) Train(sentences TupleSlice, iterations int)
Train an Averaged Perceptron model based on sentences.
type TupleSlice ¶
type TupleSlice [][][]string
TupleSlice is a slice of tuples in the form (words, tags).
func ReadTagged ¶
func ReadTagged(text, sep string) TupleSlice
ReadTagged converts pre-tagged input into a TupleSlice suitable for training.
Example ¶
tagged := "Pierre|NNP Vinken|NNP ,|, 61|CD years|NNS" fmt.Println(ReadTagged(tagged, "|"))
Output: [[[Pierre Vinken , 61 years] [NNP NNP , CD NNS]]]
func (TupleSlice) Swap ¶
func (t TupleSlice) Swap(i, j int)
Swap switches the ith and jth elements in a Tuple.