This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func learn(classifier *bayesian.Classifier) { | |
| classifier.Learn(businessFiles, Business) | |
| classifier.Learn(techFiles, Tech) | |
| } | |
| func enumerateClasses() { | |
| businessDirectory := enumerateDirectory(businessDirectoryLocation) // retrieves a list of all filenames stored in the directory. | |
| for _, file := range businessDirectory { | |
| fileContent := readFile(file) // returns the entire contents of the files as a string. | |
| businessFiles = append(businessFiles, fileContent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func enumerateDirectory(location string) []string { | |
| var files []string | |
| listing, err := ioutil.ReadDir(location) | |
| if err != nil { | |
| panic(err) | |
| } | |
| for _, l := range listing { | |
| files = append(files, location+"/"+l.Name()) | |
| } | |
| return files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package levenshtein | |
| import ( | |
| "unicode/utf8" | |
| ) | |
| func computeLevenshteinValue(a, b string) int { | |
| f := make([]int, utf8.RuneCountInString(b)+1) | |
| for j := range f { |
NewerOlder