spell

package
v0.0.0-...-8c8dd33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2020 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

package spell implements a rudementary spelling checker/suggester.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTrans []func(*Spell, []rune, int)

DefaultTrans is the set of default transformations: Remove, Transpose, Replace, Insert

Functions

func Insert

func Insert(s *Spell, word []rune, depth int)

Insert every rune in s.Runes in between each rune in word

func Remove

func Remove(s *Spell, word []rune, depth int)

Remove each rune in word

func Replace

func Replace(s *Spell, word []rune, depth int)

Replace each rune in a word with every rune from s.Runes.

func Transpose

func Transpose(s *Spell, word []rune, depth int)

Transpose each adjacement pair of runes in word

Types

type Spell

type Spell struct {
	Words trie.Trie
	Found trie.Trie
	Runes []rune
	Trans []func(*Spell, []rune, int)
}

func (*Spell) Check

func (s *Spell) Check(word []rune, depth int)

Check for a new valid word at depth 0 or recurse through transformations at depth > 0. If depth is 0 and word is a new valid word (exists in words trie but not in found trie) then add it to s.Found.

func (*Spell) ReadWords

func (s *Spell) ReadWords(reader io.Reader) error

ReadWords reads all words from reader (one per line) into s.Words.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL