1 | dictionary = {}
|
2 |
|
3 | def exists(word):
|
4 | """Tell whether a word exists in the dictionary.
|
5 |
|
6 | Returns a true or false value only. Is meant to be quite fast.
|
7 | """
|
8 | return word in dictionary
|
9 |
|
10 |
|
11 | def check(word, suggestions=1):
|
12 | """Return a suggested spelling for the given word.
|
13 |
|
14 | The optional parameter is used to specify how many alternate spellings the dictionary will return for the given word. If the word is in the dicionary, the first result returned will be the word itself.
|
15 | """
|
16 |
|
17 | def spelcheck(document, option=''):
|
18 | """Spell-check an entire document.
|
19 |
|
20 | When called with no other parameters, spelcheck will check every word in the given document against its dictionary, and return a list of problem words, their line numbers, and a suggested correction.
|
21 | When called with 'v' as a second parameter, spelcheck will return multiple suggestions for each mis-spelled word.
|
22 | When called with 'o' as a second parameter, spelcheck will return the given document with each problem word replaced by its most probable correct spelling (and no change for those words with no identifiable correct spelling.)
|
23 | """
|
24 | pass
|
25 |
|
26 | def add_word(word):
|
27 | """Adds a word to the current dictionary."""
|
28 | pass
|
29 |
|
30 | def delete_word(word):
|
31 | """Deletes this word from the current dictionary."""
|
32 | pass
|
33 |
|
34 | def import_dictionary(filename):
|
35 | """Import the given dictionary file into the spell-checker.
|
36 |
|
37 | The argument is a string representing the filename."""
|
38 | file = open(filename)
|
39 | for word in file:
|
40 | word = word.strip()
|
41 | dictionary[word] = 1
|
42 |
|
43 | def export_dictionary():
|
44 | """Exports the current dictionary in speling.py's proprietary format."""
|
45 | pass
|
46 |
|
47 | def import_rules(ruleset):
|
48 | """Import a given set of phonetic substitution rules for use by the dictionary.
|
49 |
|
50 | This function is important to the recent internationalisation attempts by the makers of speling.py. Language packages may be downloaded from our website, http://zesty.ca/spel, and loaded by calling import_dictionary and import_rules.
|
51 | """ |