vocabulary

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2020 License: BSD-2-Clause Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vocabulary

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

Vocabulary stores ID-term bidirectional associations.

func FromJSONFile

func FromJSONFile(filename string) (*Vocabulary, error)

FromJSONFile reads a vocabulary from JSON file.

func NewVocabulary

func NewVocabulary() *Vocabulary

NewVocabulary returns a new empty vocabulary.

func (*Vocabulary) AddTerm

func (v *Vocabulary) AddTerm(term string)

AddTerm adds a new term to the vocabulary. If the term does not yet exist in the vocabulary, a new ID is associated to it, corresponding to the current vocabulary size. Otherwise, if the string already exists, no insertion is performed.

func (*Vocabulary) GetID

func (v *Vocabulary) GetID(str string) (int, bool)

GetID returns the ID associated to the given string, and whether it was found.

func (*Vocabulary) GetString

func (v *Vocabulary) GetString(id int) (string, bool)

GetString returns the string associated to the given ID, and whether it was found.

func (*Vocabulary) Size

func (v *Vocabulary) Size() int

Size returns the size of the Vocabulary.

Jump to

Keyboard shortcuts

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