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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
if not sfMainDic:
sfMainDic = dDefaultDictionaries.get(sLangCode, "")
self.oMainDic = self._loadDictionary(sfMainDic, True)
self.oExtendedDic = self._loadDictionary(sfExtendedDic)
self.oPersonalDic = self._loadDictionary(sfPersonalDic)
self.oTokenizer = None
def _loadDictionary (self, sfDictionary, bNecessary=False):
"returns an IBDAWG object"
if not sfDictionary:
return None
try:
return ibdawg.IBDAWG(sfDictionary)
except Exception as e:
if bNecessary:
raise Exception(str(e), "Error: <" + sfDictionary + "> not loaded.")
print("Error: <" + sfDictionary + "> not loaded.")
traceback.print_exc()
return None
def loadTokenizer (self):
self.oTokenizer = tokenizer.Tokenizer(self.sLangCode)
def getTokenizer (self):
if not self.oTokenizer:
self.loadTokenizer()
return self.oTokenizer
def setMainDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
self.oMainDic = self._loadDictionary(sfDictionary)
return bool(self.oMainDic)
def setExtendedDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
self.oExtendedDic = self._loadDictionary(sfDictionary)
return bool(self.oExtendedDic)
def setPersonalDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
self.oPersonalDic = self._loadDictionary(sfDictionary)
return bool(self.oPersonalDic)
# parse text functions
def parseParagraph (self, sText, bSpellSugg=False):
if not self.oTokenizer:
self.loadTokenizer()
|
|
|
|
|
|
|
|
|
|
|
|
|
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
if not sfMainDic:
sfMainDic = dDefaultDictionaries.get(sLangCode, "")
self.oMainDic = self._loadDictionary(sfMainDic, True)
self.oExtendedDic = self._loadDictionary(sfExtendedDic)
self.oPersonalDic = self._loadDictionary(sfPersonalDic)
self.oTokenizer = None
def _loadDictionary (self, source, bNecessary=False):
"returns an IBDAWG object"
if not source:
return None
try:
return ibdawg.IBDAWG(source)
except Exception as e:
if bNecessary:
raise Exception(str(e), "Error: <" + str(source) + "> not loaded.")
print("Error: <" + str(source) + "> not loaded.")
traceback.print_exc()
return None
def loadTokenizer (self):
self.oTokenizer = tokenizer.Tokenizer(self.sLangCode)
def getTokenizer (self):
if not self.oTokenizer:
self.loadTokenizer()
return self.oTokenizer
def setMainDictionary (self, source):
"returns True if the dictionary is loaded"
self.oMainDic = self._loadDictionary(source)
return bool(self.oMainDic)
def setExtendedDictionary (self, source):
"returns True if the dictionary is loaded"
self.oExtendedDic = self._loadDictionary(source)
return bool(self.oExtendedDic)
def setPersonalDictionary (self, source):
"returns True if the dictionary is loaded"
self.oPersonalDic = self._loadDictionary(source)
return bool(self.oPersonalDic)
# parse text functions
def parseParagraph (self, sText, bSpellSugg=False):
if not self.oTokenizer:
self.loadTokenizer()
|