Grammalecte  Check-in [a9c5ccc29c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[graphspell] suggestions for French language: add words with apostrophes when it seems relevant
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fr
Files: files | file ages | folders
SHA3-256:a9c5ccc29c46c178b65df8152ee4e98912414b2a7183995eebca05e19070c576
User & Date: olr 2019-05-14 12:23:33
Context
2019-05-14
12:58
[graphspell][fx][js] add default suggestions module check-in: c3cdee9c76 user: olr tags: fx, graphspell, trunk
12:23
[graphspell] suggestions for French language: add words with apostrophes when it seems relevant check-in: a9c5ccc29c user: olr tags: fr, trunk
10:02
[fr] nr: conf verbe/ppas, +ajustements check-in: 7424c98a5b user: olr tags: fr, trunk
Changes

Changes to graphspell-js/ibdawg.js.

    75     75               if (lRes.length > nSuggLimit) {
    76     76                   break;
    77     77               }
    78     78           }
    79     79           lRes = char_player.filterSugg(lRes);
    80     80           if (this.sWord.gl_isUpperCase()) {
    81     81               lRes = lRes.map((sSugg) => { return sSugg.toUpperCase(); });
           82  +            lRes = [...new Set(lRes)];
    82     83           }
    83     84           else if (this.sWord.slice(0,1).gl_isUpperCase()) {
    84     85               lRes = lRes.map((sSugg) => { return sSugg.slice(0,1).toUpperCase() + sSugg.slice(1); });
           86  +            lRes = [...new Set(lRes)];
    85     87           }
    86     88           return lRes.slice(0, nSuggLimit);
    87     89       }
    88     90   
    89     91       reset () {
    90     92           this.aSugg.clear();
    91     93           this.dSugg.clear();
................................................................................
   268    270                   if (sWord.gl_isUpperCase()) {
   269    271                       if (this.bAcronymValid) {
   270    272                           return true;
   271    273                       }
   272    274                       return !!(this.lookup(sWord.toLowerCase()) || this.lookup(sWord.gl_toCapitalize()));
   273    275                   }
   274    276                   return !!this.lookup(sWord.slice(0, 1).toLowerCase() + sWord.slice(1));
   275         -            } else {
   276         -                return !!this.lookup(sWord.toLowerCase());
   277    277               }
          278  +            return !!this.lookup(sWord.toLowerCase());
   278    279           }
   279    280           if (sWord.slice(0,1).gl_isDigit()) {
   280    281               return true;
   281    282           }
   282    283           return false;
   283    284       }
   284    285   
................................................................................
   374    375                   oSuggResult.addSugg(sNewWord);
   375    376                   for (let sTail of this._getTails(iAddr)) {
   376    377                       oSuggResult.addSugg(sNewWord+sTail);
   377    378                   }
   378    379                   return;
   379    380               }
   380    381               else if ( (sNewWord.length + sRemain.length == oSuggResult.sWord.length) && oSuggResult.sWord.toLowerCase().startsWith(sNewWord.toLowerCase()) && this.isValid(sRemain) ) {
          382  +                if (this.sLangCode == "fr"
          383  +                    && ["l", "d", "n", "m", "t", "s", "c", "j", "qu", "lorsqu", "puisqu", "quoiqu", "jusqu", "quelqu"].includes(sNewWord.toLowerCase()) && char_player.aVowel.has(sRemain.slice(0,1))) {
          384  +                    oSuggResult.addSugg(sNewWord+"’"+sRemain);
          385  +                }
   381    386                   oSuggResult.addSugg(sNewWord+" "+sRemain);
   382    387               }
   383    388           }
   384    389           if (nDist > oSuggResult.nDistLimit) {
   385    390               return;
   386    391           }
   387    392   

Changes to graphspell/ibdawg.py.

     9      9   import traceback
    10     10   import pkgutil
    11     11   import re
    12     12   from functools import wraps
    13     13   import time
    14     14   import json
    15     15   import binascii
           16  +from collections import OrderedDict
    16     17   
    17     18   #import logging
    18     19   #logging.basicConfig(filename="suggestions.log", level=logging.DEBUG)
    19     20   
    20     21   from . import str_transform as st
    21     22   from . import char_player as cp
    22     23   from .echo import echo
................................................................................
    73     74           for nDist, lSugg in self.dSugg.items():
    74     75               if nDist <= self.nDistLimit:
    75     76                   lRes.extend(lSugg)
    76     77                   if len(lRes) > nSuggLimit:
    77     78                       break
    78     79           lRes = list(cp.filterSugg(lRes))
    79     80           if self.sWord.isupper():
    80         -            lRes = list(map(lambda sSugg: sSugg.upper(), lRes))
           81  +            lRes = list(OrderedDict.fromkeys(map(lambda sSugg: sSugg.upper(), lRes))) # use dict, when Python 3.6+
    81     82           elif self.sWord[0:1].isupper():
    82         -            lRes = list(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes))  # dont’ use <.istitle>
           83  +            # dont’ use <.istitle>
           84  +            lRes = list(OrderedDict.fromkeys(map(lambda sSugg: sSugg[0:1].upper()+sSugg[1:], lRes))) # use dict, when Python 3.6+
    83     85           return lRes[:nSuggLimit]
    84     86   
    85     87       def reset (self):
    86     88           "clear data"
    87     89           self.aSugg.clear()
    88     90           self.dSugg.clear()
    89     91   
................................................................................
   333    335           if int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask:
   334    336               if not sRemain:
   335    337                   oSuggResult.addSugg(sNewWord, nDeep)
   336    338                   for sTail in self._getTails(iAddr):
   337    339                       oSuggResult.addSugg(sNewWord+sTail, nDeep)
   338    340                   return
   339    341               if (len(sNewWord) + len(sRemain) == len(oSuggResult.sWord)) and oSuggResult.sWord.lower().startswith(sNewWord.lower()) and self.isValid(sRemain):
          342  +                if self.sLangCode == "fr" and sNewWord.lower() in ("l", "d", "n", "m", "t", "s", "c", "j", "qu", "lorsqu", "puisqu", "quoiqu", "jusqu", "quelqu") and sRemain[0:1] in cp.aVowel:
          343  +                    oSuggResult.addSugg(sNewWord+"’"+sRemain)
   340    344                   oSuggResult.addSugg(sNewWord+" "+sRemain)
   341    345           if nDist > oSuggResult.nDistLimit:
   342    346               return
   343    347           cCurrent = sRemain[0:1]
   344    348           for cChar, jAddr in self._getCharArcs(iAddr):
   345    349               if cChar in cp.d1to1.get(cCurrent, cCurrent):
   346    350                   self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump, nDist, nDeep+1, jAddr, sNewWord+cChar)