[go: up one dir, main page]

Menu

[r19]: / SpellChecker.py  Maximize  Restore  History

Download this file

58 lines (43 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
# -*- coding: utf-8 -*-
try:
import enchant
except:
print "Spell checker pyenchant is not available."
class NeatSpell:
"""
Provides the necessary functions for spellchecking.
Uses the enchant module.
"""
def __init__(self):
"""
__init__
Initializes the enchant module, sets the language
dictionary.
"""
try:
self.dictionary = enchant.Dict()
except enchant.Error:
print "The Dictionary could not be identified.\n Falling back to English."
self.dictionary = enchant.Dict("en_US")
def CheckWord(self, word):
"""
CheckWord
Calls enchant to check the suplied argument word.
"""
return self.dictionary.check(word)
def GetSuggestion(self, word):
"""
GetSuggestion
Calls the enchant library to generate
spelling suggestion for the suplied argument
word.
"""
return self.dictionary.suggest(word)
def ShowSpellDialog(self, event):
""""
ShowSpellDialog
not implemented
"""
pass
WordSpeller = NeatSpell()