62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
sPersonalDicJSON = self.xOptionNode.getPropertyValue("personal_dic")
if sPersonalDicJSON:
try:
personal_dic = json.loads(sPersonalDicJSON)
except:
print("Graphspell: wrong personal_dic")
traceback.print_exc()
self.oGraphspell = SpellChecker("fr", "fr-"+sMainDicName+".bdic", "", "", personal_dic)
self.loadHunspell()
# print("Graphspell: init done")
except:
print("Graphspell: init failed")
traceback.print_exc()
def loadHunspell (self):
# Hunspell is a fallback spellchecker
try:
self.xHunspell = self.xSvMgr.createInstance("org.openoffice.lingu.MySpellSpellChecker")
except:
print("Hunspell: init failed")
traceback.print_exc()
|
|
|
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
sPersonalDicJSON = self.xOptionNode.getPropertyValue("personal_dic")
if sPersonalDicJSON:
try:
personal_dic = json.loads(sPersonalDicJSON)
except:
print("Graphspell: wrong personal_dic")
traceback.print_exc()
self.oGraphspell = SpellChecker("fr", "fr-"+sMainDicName+".bdic", "", personal_dic)
self.loadHunspell()
# print("Graphspell: init done")
except:
print("Graphspell: init failed")
traceback.print_exc()
def loadHunspell (self):
# Hunspell is a fallback spellchecker
try:
self.xHunspell = self.xSvMgr.createInstance("org.openoffice.lingu.MySpellSpellChecker")
except:
print("Hunspell: init failed")
traceback.print_exc()
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
def hasLocale (self, aLocale):
if aLocale in self.locales:
return True
for e in self.locales:
if aLocale.Language == e.Language and (e.Country == aLocale.Country or e.Country == ""):
return True
return False
def getLocales (self):
return self.locales
# XSpellChecker
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellChecker.html
def isValid (self, aWord, rLocale, aProperties):
try:
aWord = zElidedWords.sub("", aWord.rstrip("."), count=1)
return self.oGraphspell.isValidToken(aWord)
# return self.xHunspell.isValid(aWord, self.xHunspellLocale, aProperties)
|
|
|
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
def hasLocale (self, aLocale):
if aLocale in self.locales:
return True
for e in self.locales:
if aLocale.Language == e.Language and (e.Country == aLocale.Country or e.Country == ""):
return True
return False
def getLocales (self):
return self.locales
# XSpellChecker
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellChecker.html
def isValid (self, aWord, rLocale, aProperties):
try:
aWord = zElidedWords.sub("", aWord.rstrip("."), count=1)
return self.oGraphspell.isValidToken(aWord)
# return self.xHunspell.isValid(aWord, self.xHunspellLocale, aProperties)
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
#self.xFallbackSpellChecker = self.xSvMgr.createInstance(sSpellchecker)
#if self.xFallbackSpellChecker:
# print("Spell checker: %s" % xSpellChecker)
# break
class SpellAlternatives (unohelper.Base, XSpellAlternatives):
def __init__ (self, sWord, lSugg):
try:
self.sWord = sWord
self.lSugg = lSugg
self.xLocale = Locale('fr', 'FR', '')
except:
traceback.print_exc()
# XSpellAlternatives
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellAlternatives.html
def getWord (self):
return self.sWord
def getLocale (self):
return self.xLocale
def getFailureType (self):
return 4
# IS_NEGATIVE_WORD = 2
# The word is a negative one, that is, it should not be used.
# CAPTION_ERROR = 3
# The capitalization of the word is wrong.
# SPELLING_ERROR = 4
# The spelling of the word is wrong (or at least not known to be correct).
# No difference -> red underline
def getAlternativesCount (self):
return len(self.lSugg)
def getAlternatives (self):
return self.lSugg
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(Graphspell, "net.grammalecte.graphspell", ("com.sun.star.linguistic2.SpellChecker",),)
|
|
|
|
|
|
|
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
#self.xFallbackSpellChecker = self.xSvMgr.createInstance(sSpellchecker)
#if self.xFallbackSpellChecker:
# print("Spell checker: %s" % xSpellChecker)
# break
class SpellAlternatives (unohelper.Base, XSpellAlternatives):
def __init__ (self, sWord, lSugg):
try:
self.sWord = sWord
self.lSugg = lSugg
self.xLocale = Locale('fr', 'FR', '')
except:
traceback.print_exc()
# XSpellAlternatives
# http://www.openoffice.org/api/docs/common/ref/com/sun/star/linguistic2/XSpellAlternatives.html
def getWord (self):
return self.sWord
def getLocale (self):
return self.xLocale
def getFailureType (self):
return 4
# IS_NEGATIVE_WORD = 2
# The word is a negative one, that is, it should not be used.
# CAPTION_ERROR = 3
# The capitalization of the word is wrong.
# SPELLING_ERROR = 4
# The spelling of the word is wrong (or at least not known to be correct).
# No difference -> red underline
def getAlternativesCount (self):
return len(self.lSugg)
def getAlternatives (self):
return self.lSugg
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(Graphspell, "net.grammalecte.graphspell", ("com.sun.star.linguistic2.SpellChecker",),)
|