Grammalecte  Check-in [2bcf7228cc]

Overview
Comment:[graphspell][py] fix variables name
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | graphspell | multid
Files: files | file ages | folders
SHA3-256: 2bcf7228cc69426f5ca8212f3f116f65a5f8e6e5952920123d67bd6cf2bebd13
User & Date: olr on 2018-02-13 14:23:31
Other Links: branch diff | manifest | tags
Context
2018-02-13
14:24
[graphspell][js] fix variables name check-in: 63ccb31875 user: olr tags: graphspell, multid
14:23
[graphspell][py] fix variables name check-in: 2bcf7228cc user: olr tags: graphspell, multid
13:39
[core][js] multi-dictionaries check-in: d8959f76a4 user: olr tags: core, multid
Changes

Modified graphspell/spellchecker.py from [19c7dd4df2] to [781d3c301e].

    15     15   
    16     16   dDefaultDictionaries = {
    17     17       "fr": "fr.bdic",
    18     18       "en": "en.bdic"
    19     19   }
    20     20   
    21     21   
    22         -class Spellchecker ():
           22  +class SpellChecker ():
    23     23   
    24     24       def __init__ (self, sLangCode, sfMainDic="", sfExtendedDic="", sfPersonalDic=""):
    25     25           "returns True if the main dictionary is loaded"
    26     26           self.sLangCode = sLangCode
    27     27           if not sfMainDic:
    28     28               sfMainDic = dDefaultDictionaries.get(sLangCode, "")
    29     29           self.oMainDic = self._loadDictionary(sfMainDic)
    30     30           self.oExtendedDic = self._loadDictionary(sfExtendedDic)
    31     31           self.oPersonalDic = self._loadDictionary(sfPersonalDic)
    32         -        return bool(self.oMainDic)
    33     32   
    34     33       def _loadDictionary (self, sfDictionary):
    35     34           "returns an IBDAWG object"
    36     35           if not sfDictionary:
    37     36               return None
    38     37           try:
    39     38               return ibdawg.IBDAWG(sfDictionary)
................................................................................
    68     67               return True
    69     68           if self.oPersonalDic and self.oPersonalDic.isValidToken(sToken):
    70     69               return True
    71     70           return False
    72     71   
    73     72       def isValid (self, sWord):
    74     73           "checks if sWord is valid (different casing tested if the first letter is a capital)"
    75         -        if self.oMainDic.isValid(sToken):
           74  +        if self.oMainDic.isValid(sWord):
    76     75               return True
    77         -        if self.oExtendedDic and self.oExtendedDic.isValid(sToken):
           76  +        if self.oExtendedDic and self.oExtendedDic.isValid(sWord):
    78     77               return True
    79         -        if self.oPersonalDic and self.oPersonalDic.isValid(sToken):
           78  +        if self.oPersonalDic and self.oPersonalDic.isValid(sWord):
    80     79               return True
    81     80           return False
    82     81   
    83     82       def lookup (self, sWord):
    84     83           "checks if sWord is in dictionary as is (strict verification)"
    85         -        if self.oMainDic.lookup(sToken):
           84  +        if self.oMainDic.lookup(sWord):
    86     85               return True
    87         -        if self.oExtendedDic and self.oExtendedDic.lookup(sToken):
           86  +        if self.oExtendedDic and self.oExtendedDic.lookup(sWord):
    88     87               return True
    89         -        if self.oPersonalDic and self.oPersonalDic.lookup(sToken):
           88  +        if self.oPersonalDic and self.oPersonalDic.lookup(sWord):
    90     89               return True
    91     90           return False
    92     91   
    93     92       def getMorph (self, sWord):
    94     93           "retrieves morphologies list, different casing allowed"
    95         -        lResult = self.oMainDic.getMorph(sToken)
           94  +        lResult = self.oMainDic.getMorph(sWord)
    96     95           if self.oExtendedDic:
    97         -            lResult.extends(self.oExtendedDic.getMorph(sToken))
           96  +            lResult.extends(self.oExtendedDic.getMorph(sWord))
    98     97           if self.oPersonalDic:
    99         -            lResult.extends(self.oPersonalDic.getMorph(sToken))
           98  +            lResult.extends(self.oPersonalDic.getMorph(sWord))
   100     99           return lResult
   101    100   
   102    101       def suggest (self, sWord, nSuggLimit=10):
   103    102           "generator: returns 1,2 or 3 lists of suggestions"
   104    103           yield self.oMainDic.suggest(sWord, nSuggLimit)
   105    104           if self.oExtendedDic:
   106    105               yield self.oExtendedDic.suggest(sWord, nSuggLimit)