spell

package
v2.30.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT, MIT Imports: 15 Imported by: 0

Documentation

Overview

Package spell is a pure-Go, high-performance spell checker based on Hunspell-compatible dictionaries.

Index

Constants

View Source
const (
	Prefix affixType = iota
	Suffix
)

specific Affix types

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

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

Checker is a spell-checker based on multiple dictionaries.

func NewChecker

func NewChecker(options ...CheckerOption) (*Checker, error)

NewChecker creates a spell checker from multiple Hunspell-compatible dictionaries.

func (*Checker) AddWordListFile

func (m *Checker) AddWordListFile(name string) error

AddWordListFile reads in a word list file

func (*Checker) Convert

func (m *Checker) Convert(s string) string

Convert performs character substitutions (ICONV).

func (*Checker) Dict

func (m *Checker) Dict(i int) map[string]struct{}

Dict returns the underlying dictionary for the provided index.

func (*Checker) Spell

func (m *Checker) Spell(word string) bool

Spell checks to see if a given word is in the internal dictionaries.

func (*Checker) Suggest

func (m *Checker) Suggest(word string) []string

Suggest returns a list of suggestions for a given word.

type CheckerOption

type CheckerOption func(opts *Options)

A CheckerOption is a setting that changes the checker-creation process.

func UsingDictionary

func UsingDictionary(name string) CheckerOption

UsingDictionary loads the given Hunspell-compatible dictionary.

func UsingDictionaryByPath

func UsingDictionaryByPath(dic, aff string) CheckerOption

UsingDictionaryByPath loads the given Hunspell-compatible dictionary using the given local paths.

func WithDefault

func WithDefault(load bool) CheckerOption

WithDefault specifies if Vale's default dictionary should be loaded.

func WithPath

func WithPath(path string) CheckerOption

WithPath specifies the location of Hunspell-compatible dictionaries.

type Options

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

Options controls the checker-creation process:

Jump to

Keyboard shortcuts

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