check

package
v0.0.0-...-b2127f6 Latest Latest
Warning

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

Go to latest
Published: May 12, 2016 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alphabet

type Alphabet string

An Alphabet represents the set of character allowed in a word.

func NewAlphabet

func NewAlphabet(letters string) *Alphabet

NewAlphabet creates an alphabet from the given slice of characters.

func (Alphabet) Contains

func (ab Alphabet) Contains(r rune) bool

Contains returns true iff the character exists in the alphabet.

func (Alphabet) Letter

func (ab Alphabet) Letter(index int) (letter rune, ok bool)

Letter returns the character at a given index into the alphabet. ok == true iff a character at the index exists.

func (Alphabet) Size

func (ab Alphabet) Size() int

Size returns the number of characters.

type Checker

type Checker interface {
	// IsMisspelled returns false if the word is classified as misspelled.
	// If misspelled, suggested words may be nil or a slice with len > 0.
	IsMisspelled(word string, dict Dict) (res bool, suggested []string)
}

A Checker classifies misspelled words.

func And

func And(checkers ...Checker) Checker

func Or

func Or(checkers ...Checker) Checker

type DeltaChecker

type DeltaChecker struct {
	AllowedIns   uint
	AllowedDel   uint
	AllowedSwaps uint
	AllowedMods  uint
}

A DeltaChecker classifies a word as misspelled if its length is >= MinLength and is within a given number of character deletions, inserts, and consecutive swaps.

func (DeltaChecker) IsMisspelled

func (c DeltaChecker) IsMisspelled(word string, dict Dict) (bool, []string)

type Dict

type Dict interface {
	// Contains returns true iff the dictionary contains the word
	Contains(word []rune) bool
	// Alphabet returns the alphabet of the dictionary's language
	Alphabet() Alphabet
}

A Dict represents a dictionary of words.

type MinLengthChecker

type MinLengthChecker uint8

A MinLengthChecker classifies a word as misspelled iff the length of the word is greater than a given value.

func (MinLengthChecker) IsMisspelled

func (c MinLengthChecker) IsMisspelled(word string, dict Dict) (bool, []string)

type StrictChecker

type StrictChecker struct{}

A StrictChecker classifies a word as misspelled if it does not exist in the dictionary provided.

func (StrictChecker) IsMisspelled

func (StrictChecker) IsMisspelled(word string, dict Dict) (bool, []string)

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

A Trie represents the head node of a trie.

func NewTrie

func NewTrie(alphabet Alphabet) *Trie

NewTrie create a Trie from a given Alphabet.

func (*Trie) Add

func (t *Trie) Add(word string) bool

Add adds a word to the trie and returns true if the word already exists or is added successfully, false otherwise.

func (*Trie) Alphabet

func (t *Trie) Alphabet() Alphabet

func (*Trie) Contains

func (t *Trie) Contains(word []rune) bool

Jump to

Keyboard shortcuts

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