mglib

Personal IDL library for M. Galloy

single page | use frames     summary     class     fields     routine details     file attributes

strings/

mg_spellcorrect.pro


Returns the correct spelling of the given word. Based on Peter Norvig's Python spelling corrector.

Examples

Try the main-level program at the end of the file:

IDL> .run mg_spellcorrect "corect" should be spelled "correct" "information" was spelled correctly "informtion" should be spelled "information" "known" was spelled correctly

Author information

Author

Michael Galloy

Other file information

Requires:

IDL 8.0

Routines

Routines from mg_spellcorrect.pro

result = mg_spellcorrect_generate_hash()

Generates the known words hash.

result = mg_spellcorrect_edits1( [word])

Create hash of all edits of a word that are only 1 character off from the original.

result = mg_spellcorrect_known_edits2( [word] [, known_hash=hash: string->long])

Create hash of all correct edits of a word that are only 2 edits off from the original.

result = mg_spellcorrect_known(words [, known_hash=hash: string->long])

Creates a hash of the known words in a given hash of words.

result = mg_spellcorrect(word [, known_words=hash object] [, /correct])

Corrects the spelling of a word.

Routine details

top mg_spellcorrect_generate_hash

result = mg_spellcorrect_generate_hash()

Generates the known words hash.

Return value

hash: string->long

top mg_spellcorrect_edits1

result = mg_spellcorrect_edits1( [word])

Create hash of all edits of a word that are only 1 character off from the original.

Return value

hash: string->byte

Parameters

word in optional type=string

word to find edits of

top mg_spellcorrect_known_edits2

result = mg_spellcorrect_known_edits2( [word] [, known_hash=hash: string->long])

Create hash of all correct edits of a word that are only 2 edits off from the original.

Return value

hash: string->byte

Parameters

word in optional type=string

word to find edits of

Keywords

known_hash in out optional type=hash: string->long

hash of known word frequencies

top mg_spellcorrect_known

result = mg_spellcorrect_known(words [, known_hash=hash: string->long])

Creates a hash of the known words in a given hash of words.

Return value

hash: string->byte

Parameters

words in required type=hash: string->byte

Keywords

known_hash in out optional type=hash: string->long

hash of known word frequencies

top mg_spellcorrect

result = mg_spellcorrect(word [, known_words=hash object] [, /correct])

Corrects the spelling of a word.

Return value

string

Parameters

word in required type=string

string to check spelling of

Keywords

known_words in out optional type=hash object

can be passed in to avoid reading/construction the known words frequency table; will be passed out if given a named variable

correct out optional type=boolean

set to a named variable to indicate if the word passed in was correctly spelled

File attributes

Modification date: Wed May 14 15:07:14 2014
Lines: 119
Docformat: rst rst
Personal library of Michael Galloy
Contact me if you have enhancement requests or bug fixes.