Skip to content

Commit d92bbbd

Browse files
committed
Improved documentation
1 parent 766a1bd commit d92bbbd

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

dictionary.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ import (
1010
)
1111

1212
const (
13-
// ESAlphabet represents the alphabet of the Spanish vocabulary
13+
// ESAlphabet represents the alphabet of the Spanish vocabulary.
1414
ESAlphabet = "abcdefghijklmnopqrstuvwxyzñáéíóúü"
15-
// ENAlphabet represents the alphabet of the English vocabulary
15+
// ENAlphabet represents the alphabet of the English vocabulary.
1616
ENAlphabet = "abcdefghijklmnopqrstuvwxyz"
1717
)
1818

1919
// Dictionary object is the main structure of the algorithm and it contains
20-
// the alphabet in and the words that are built on top of that.
20+
// the alphabet in and the words.
2121
type Dictionary struct {
22-
// The alphabet which the dictionary is built
22+
// Alphabet of the dictionary.
2323
Alphabet string
24-
// A map that contains the word and the number of apparitions on texts
25-
// it will help to calculate the most probable correction
24+
// Words is a map that contains the word and the frequency number on texts,
25+
// it will help to calculate the most probable correction.
2626
Words map[string]int
2727
filePath string
2828
}
@@ -61,7 +61,7 @@ func LoadDictionary(filePath string) (*Dictionary, error) {
6161

6262
// TrainFromTextFile reads all the words that can be found in the text file specified path,
6363
// those will be used to train the dictionary.
64-
// It returns any read or write errors encountered.
64+
// It returns any read/write errors encountered.
6565
func (d *Dictionary) TrainFromTextFile(textFilePath string) error {
6666
text, err := ioutil.ReadFile(textFilePath)
6767
if err != nil {

spelling.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ func (s *Spelling) findMaxFreqWord(words chan string) string {
6868
return correction
6969
}
7070

71+
// genAltsOf finds all possible combinations swapping the order of the alphabet to generate new
72+
// possible words.
7173
func (s *Spelling) genAltsOf(word string, words chan string) {
7274
splits := [][]string{}
7375
for i := 0; i < len(word)+1; i++ {

0 commit comments

Comments
 (0)