Skip to content

Instantly share code, notes, and snippets.

@RathanakSreang
Last active April 21, 2019 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RathanakSreang/c8ae832c2268cc675c466676e69d74c4 to your computer and use it in GitHub Desktop.
Save RathanakSreang/c8ae832c2268cc675c466676e69d74c4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/sajari/fuzzy"
)
func main() {
model := fuzzy.NewModel()
model.SetThreshold(1)
model.SetDepth(5)
words := []string{
"កក", "កករ", "កកាត", "កកាយ", "កកិចកកុច",
"កកិត", "កកិល", "កកូរ", "កកេបកកាប", "កកេរ", "កកេះ",
"កកែកកកោក", "កកែកករ", "កកែងកកោង", "កកែប", "កកោក",
"កកោស", "កកោះ", "កក់", "កក៌ដ", "កក្កដ", "កក្រិត", "កក្រើក",
// "កក្រោះ", "កក្លាក់", "កក្អាក", "កក្អាយ", "កក្អិច", "កក្អិល",
// "កក្អឹក", "កក្អៀក", "កក្អៀច", "កខិកកខក់", "កខិបកខុប", "កខឹក",
// "កខុប", "កខ្វក់", "កខ្វិក", "កខ្វេសកខ្វាស", "កង", "កងកន់", "កងកេង",
// "កងចៅ", "កងទ័ព", "កងព័ន្ធ", "កងមាស", "កងសោយ", "កង់", "កង្កុញ",
// "កង្កួច", "កង្កួញ", "កង្កែប", "កង្កែប​កូប", "កង្កែប​ប្រុយ", "កង្កែប​អាចម៍​គោ",
// "កង្ខា", "កង្ខើញ", "កង្វល់", "កង្វាក់", "កង្វារ", "កង្វិន", "កង្វេរ",
// "កង្ហារ", "កង្ហិច", "កង្ហែន", "កច្ចាយនូបត្ថម្ភកៈ", "កច្ចាយនៈ", "កញ្ចក",
// "កញ្ចក់", "កញ្ចប់", "កញ្ចប់កញ្ចូវ", "កញ្ចាញ់ចេក", "កញ្ចាញ់ច្រាស", "កញ្ចាម",
// "កញ្ចាស់", "កញ្ចាំង", "កញ្ចឹងក", "កញ្ចុំ", "កញ្ចុះ", "កញ្ចូញ", "កញ្ចែ",
// "កញ្ចោង", "កញ្ចោត", "កញ្ចោប", "កញ្ច្រង់", "កញ្ច្រឹក", "កញ្ច្រឺប",
// "កញ្ច្រែង", "កញ្ឆក់", "កញ្ឆក់កញ្ឆែង", "កញ្ឆត", "កញ្ឆល", "កញ្ឆា",
// "កញ្ឆាញ", "កញ្ឆាត់", "កញ្ឆិត", "កញ្ឆិល", "កញ្ឆឹម", "កញ្ឆួង",
}
fmt.Println("Start train complete")
fmt.Println(len(words))
model.Train(words)
fmt.Println("Train complete")
// Check Spelling
fmt.Println("\nSPELL CHECKS")
fmt.Println("កកែករ => ", model.SpellCheck("កកែករ"))
fmt.Println("កោះ => ", model.SpellCheck("កោះ"))
fmt.Println("កកិ => ", model.SpellCheck("កកិ"))
// Suggest completions
fmt.Println("\nQUERY SUGGESTIONS")
fmt.Println(" \"កលិ\". Did you mean?: ", model.Suggestions("កលិ", false))
// save the trained model
model.Save("modal.dict")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment