| Spell Checker Primitives | |
| Macros | |
| spell_buffer | Spell the specified buffer. |
| spell_control | Spell control. |
| spell_dictionary | Spell dictionary modifications. |
| spell_distance | Edit distance. |
| spell_string | Spell the specified word or line. |
| spell_suggest | Suggest spelling of the the specified word. |
list spell_buffer( int start_line, [int end_line], [int tokenize = 1], [int suggest] )
Spell the specified buffer.
The spell_buffer() primitive spell checks the specified lines within the current buffer.
The string passed in should only be split on white space characters.
Furthermore, between calls to reset each string should be passed in exactly once and in the order they appeared in the document. Passing in stings out of order, skipping strings or passing them in more than once may lead to undefined results.
| start_line | Integer line number, being the first line at which spell |
| end_line | Optional integer line number, denoting the line at which spell check shall complete. If omitted checks are performed until the end-of-buffer. |
| tokenize | Optional integer flag, if specified as zero the buffer content shall not be split into tokens during parsing. |
| suggest | Optional integer flag, if specified as non-zero spelling suggestions shall be returned against each misspelt word. |
The spell_buffer() primitive returns a list of possible spelling errors in the form.
[<word>, <suggest-list|NULL>, <offset>, <column>, <line> [, <count>]]
A GriefEdit extension.
declare spell_control( int action, ... )
Spell control.
The spell_control() primitive manipulates the spell engine attribute associated with the specified action. Additional arguments are specific to the action or attribute being modified.
| action | Integer identifier of the engine attribute to be manipulated. |
| ... | Action specific value. |
| Action |
Description |
|---|---|
| SPELL_DESCRIPTION |
Spell implementation description, returns a string containing the name of the current speller. |
| SPELL_DICTIONARIES |
List of available dictionaries, retrieves a list of string each the name of a available dictionary. |
| SPELL_LOAD |
Load a personal dictionary. |
| SPELL_SAVE |
Save to a personal dictionary. |
| SPELL_ADD |
Add to the personal dictionary. |
| SPELL_IGNORE |
Add to the spell ignore list. |
| SPELL_REPLACE |
Add to the spell replacement list. |
| SPELL_LANG_ADD |
n/a |
| SPELL_LANG_PRIMARY |
n/a |
| SPELL_LANG_REMOVE |
n/a |
The spell_control() primitive usually, on success returns zero, otherwise -1 on error.
A few spell_control requests return non-integer values, either a string or list, based on the attribute that was manipulated by the specified action, see table above.
A GriefEdit extension.
int spell_dictionary( int, string|list )
Spell dictionary modifications.
The spell_dictionary() primitive is reserved.
n/a
The spell_dictionary() primitive returns -0 on success, otherwise -1 on error.
A GriefEdit extension.
spell_buffer, spell_string, spell_suggest, spell_control, spell_distance
int spell_distance( string a, string b )
Edit distance.
The spell_distance() primitive computes the “distance” between two words by counting the number of insert, replace, and delete operations required to permute one word into another.
In general the fewer operations required, the closer the match. Some implementations assign varying scores to the insert, replace, and delete operations. Another common variation varies which operations are considered when computing the distance; for example, the replace operation may not be considered, thereby defining the edit distance solely in terms of insert and delete options.
This algorithm uses one of the more popular algorithms in the edit distance known as the “Levenshtein distance”.
The costs assigned to each move are equal, that is of the following operations have a cost of 1.
| s1 | String one. |
| s2 | Second string. |
The spell_distance() primitive returns the edit distance between the two words.
A GriefEdit extension.
int spell_string( string word, [int length], [int tokenize = 0], [int suggest = FALSE] )
Spell the specified word or line.
The spell_string() primitive spell checks the specified string word
The string passed in should only be split on white space characters.
Furthermore, between calls to reset each string should be passed in exactly once and in the order they appeared in the document. Passing in stings out of order, skipping strings or passing them in more than once may lead to undefined results.
| word | String containing the text to be checked. |
| length | Optional integer, stating the number of characters within the string to be parsed. |
| tokenize | Optional integer flag, if specified as non-zero the string content shall be split into tokens during parsing. |
| suggest | Optional integer flag, if specified as non-zero spelling suggestions shall be returned against each misspelt word. |
The spell_string() primitive returns a value dependent on the input mode.
For word checks, 0 on success, other non-zero.
For string or line checks, list of possible incorrect words offset/line + length pairs with optional suggestion list, with offsets starting from 1.
[<word>, <suggest-list|NULL>, <offset>, <column>]
A GriefEdit extension.
list spell_suggest( string word, [int length] )
Suggest spelling of the the specified word.
The spell_distance() primitive spell checks the specified word building a list of possible suggestions.
| word | xxx |
| length | xxx |
The spell_suggest() primitive returns a list of possible suggestions, otherwise null.
A GriefEdit extension.
spell_buffer, spell_string, spell_control, spell_distance
$Id: $
To send feedback on this topic email: griefedit@gmail.com
Copyright © Adam Young All Rights Reserved.
Spell the specified buffer.
list spell_buffer( int start_line, [int end_line], [int tokenize = 1], [int suggest] )
Spell control.
declare spell_control( int action, ... )
Spell dictionary modifications.
int spell_dictionary( int, string|list )
Edit distance.
int spell_distance( string a, string b )
Spell the specified word or line.
int spell_string( string word, [int length], [int tokenize = 0], [int suggest = FALSE] )
Suggest spelling of the the specified word.
list spell_suggest( string word, [int length] )