Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Levenshtein ¶
Levenshtein computes the Levenshtein distance for two words.
Types ¶
type DefaultSemanticMatcher ¶
type DefaultSemanticMatcher struct {
// contains filtered or unexported fields
}
DefaultSemanticMatcher is a SemanticMatcher which uses a simple lookup table to find the best suggestion.
func (*DefaultSemanticMatcher) Match ¶
func (sm *DefaultSemanticMatcher) Match(context string, suggestions []string) (string, bool)
Match finds the best suggestion based on the context.
func (*DefaultSemanticMatcher) Train ¶
func (sm *DefaultSemanticMatcher) Train(context, word string)
Train trains the semantic models with a word and its context.
type DefaultSpellChecker ¶
type DefaultSpellChecker struct {
// contains filtered or unexported fields
}
DefaultSpellChecker is a SpellChecker which uses a distance model to find suggestions for a misspelled word.
func (*DefaultSpellChecker) Check ¶
func (sc *DefaultSpellChecker) Check(word string) []string
Check finds correct spell suggestions for a word.
func (*DefaultSpellChecker) Train ¶
func (sc *DefaultSpellChecker) Train(words []string)
Train trains the suggestion model with a list of words.
type Processor ¶
type Processor struct { // SpellChecker is the word spell-checker. If this field is nil, the // preprocessor will use DefaultSpellChecker. SpellChecker SpellChecker // SemanticMatcher is the semantic matcher to find the best suggestion. If // this field is nil, the preprocessor will use DefaultSemanticMatcher. SemanticMatcher SemanticMatcher }
Processor is the Persian text preprocessor.
type SemanticMatcher ¶
type SemanticMatcher interface { // Match finds the best suggestion based on the context. If the best // suggestion correlates with the context, it returns true for matched, // otherwise it returns false. Match(context string, suggestions []string) (best string, matched bool) // Train trains the semantic models with a word and its context. Train(context, word string) }
SemanticMatcher provides selection of the best suggestion by its context.
type SpellChecker ¶
type SpellChecker interface { // Check finds correct spell suggestions for a word. The resulted suggestion // list should not be empty. Check(word string) []string // Train trains the suggestion model with a list of words. Train(words []string) }
SpellChecker is a word spell-checker.