Documentation ¶
Index ¶
Constants ¶
const ( // ESAlphabet represents the alphabet of the Spanish vocabulary. ESAlphabet = "abcdefghijklmnopqrstuvwxyzñáéíóúü" // ENAlphabet represents the alphabet of the English vocabulary. ENAlphabet = "abcdefghijklmnopqrstuvwxyz" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dictionary ¶
type Dictionary struct { // Alphabet of the dictionary. Alphabet string // Words is a map that contains the word and the frequency number on texts, // it will help to calculate the most probable correction. Words map[string]int // contains filtered or unexported fields }
Dictionary object is the main structure of the algorithm and it contains the alphabet in and the words.
func LoadDictionary ¶
func LoadDictionary(filePath string) (*Dictionary, error)
LoadDictionary loads a dictionary in the specified file path It returns a new Dictionary structure and any read error encountered.
func NewDictionary ¶
func NewDictionary(filePath string, alphabet string) (*Dictionary, error)
NewDictionary creates a new dictionary file at the specified path and the alphabet that correspond to it. It returns a new Dictionary structure and any write error encountered.
func (*Dictionary) TrainFromTextFile ¶
func (d *Dictionary) TrainFromTextFile(textFilePath string) error
TrainFromTextFile reads all the words that can be found in the text file specified path, those will be used to train the dictionary. It returns any read/write errors encountered.
type Spelling ¶
type Spelling struct {
// contains filtered or unexported fields
}
Spelling object contains a dictionary object The main purpose of this struct is to provide actions/features that require process the dictionary data.
func NewSpelling ¶
NewSpelling creates a new structure that contains a dictionary inside and it gets as a parameter the file path that points to the required dictionary. It returns a new Spelling structure and any read error encountered.
func (*Spelling) Correction ¶
Correction select the best possible correction for the specified word. Returns the correction if there was one.