Grammalecte  Diff

Differences From Artifact [4787045da6]:

To Artifact [aaa0229431]:


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
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):
    def _loadDictionary (self, source, bNecessary=False):
        "returns an IBDAWG object"
        if not sfDictionary:
        if not source:
            return None
        try:
            return ibdawg.IBDAWG(sfDictionary)
            return ibdawg.IBDAWG(source)
        except Exception as e:
            if bNecessary:
                raise Exception(str(e), "Error: <" + sfDictionary + "> not loaded.")
            print("Error: <" + sfDictionary + "> not loaded.")
                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, sfDictionary):
    def setMainDictionary (self, source):
        "returns True if the dictionary is loaded"
        self.oMainDic = self._loadDictionary(sfDictionary)
        self.oMainDic = self._loadDictionary(source)
        return bool(self.oMainDic)
            
    def setExtendedDictionary (self, sfDictionary):
    def setExtendedDictionary (self, source):
        "returns True if the dictionary is loaded"
        self.oExtendedDic = self._loadDictionary(sfDictionary)
        self.oExtendedDic = self._loadDictionary(source)
        return bool(self.oExtendedDic)

    def setPersonalDictionary (self, sfDictionary):
    def setPersonalDictionary (self, source):
        "returns True if the dictionary is loaded"
        self.oPersonalDic = self._loadDictionary(sfDictionary)
        self.oPersonalDic = self._loadDictionary(source)
        return bool(self.oPersonalDic)

    # parse text functions

    def parseParagraph (self, sText, bSpellSugg=False):
        if not self.oTokenizer:
            self.loadTokenizer()