Grammalecte  Check-in [11d187ec76]

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

Overview
Comment:[graphspell] suggestion: split word if both parts are valid
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | graphspell
Files: files | file ages | folders
SHA3-256:11d187ec76c3a46b08b3e2200058937160f569b3536d0014d73420c49867c063
User & Date: olr 2019-01-02 20:01:04
Context
2019-01-03
10:05
[fr] ajustements loc. adv. check-in: 89c01b3494 user: olr tags: fr, trunk
2019-01-02
20:01
[graphspell] suggestion: split word if both parts are valid check-in: 11d187ec76 user: olr tags: graphspell, trunk
13:58
[fr] html: purge des espaces insécables fins check-in: 0e847b75ad user: olr tags: fr, trunk
Changes

Changes to graphspell-js/ibdawg.js.

   353    353               }
   354    354           }
   355    355       }
   356    356   
   357    357       _suggest (oSuggResult, sRemain, nMaxSwitch=0, nMaxDel=0, nMaxHardRepl=0, nMaxJump=0, nDist=0, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=false) {
   358    358           // returns a set of suggestions
   359    359           // recursive function
   360         -        if (sRemain == "") {
   361         -            if (this._convBytesToInteger(this.byDic.slice(iAddr, iAddr+this.nBytesArc)) & this._finalNodeMask) {
          360  +        if (this._convBytesToInteger(this.byDic.slice(iAddr, iAddr+this.nBytesArc)) & this._finalNodeMask) {
          361  +            if (sRemain == "") {
   362    362                   oSuggResult.addSugg(sNewWord);
          363  +                for (let sTail of this._getTails(iAddr)) {
          364  +                    oSuggResult.addSugg(sNewWord+sTail);
          365  +                }
          366  +                return;
   363    367               }
   364         -            for (let sTail of this._getTails(iAddr)) {
   365         -                oSuggResult.addSugg(sNewWord+sTail);
          368  +            else if (this.isValid(sRemain)) {
          369  +                oSuggResult.addSugg(sNewWord+" "+sRemain);
   366    370               }
   367         -            return;
   368    371           }
   369    372           if (nDist > oSuggResult.nDistLimit) {
   370    373               return;
   371    374           }
   372    375   
   373    376           let cCurrent = sRemain.slice(0, 1);
   374    377           for (let [cChar, jAddr] of this._getCharArcs(iAddr)) {

Changes to graphspell/ibdawg.py.

   317    317                   sWord1, sWord2 = sWord.split(cSplitter, 1)
   318    318                   if self.isValid(sWord1) and self.isValid(sWord2):
   319    319                       oSuggResult.addSugg(sWord1+" "+sWord2)
   320    320   
   321    321       def _suggest (self, oSuggResult, sRemain, nMaxSwitch=0, nMaxDel=0, nMaxHardRepl=0, nMaxJump=0, nDist=0, nDeep=0, iAddr=0, sNewWord="", bAvoidLoop=False):
   322    322           # recursive function
   323    323           #logging.info((nDeep * "  ") + sNewWord + ":" + sRemain)
   324         -        if not sRemain:
   325         -            if int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask:
          324  +        if int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask:
          325  +            if not sRemain:
   326    326                   oSuggResult.addSugg(sNewWord, nDeep)
   327         -            for sTail in self._getTails(iAddr):
   328         -                oSuggResult.addSugg(sNewWord+sTail, nDeep)
   329         -            return
          327  +                for sTail in self._getTails(iAddr):
          328  +                    oSuggResult.addSugg(sNewWord+sTail, nDeep)
          329  +                return
          330  +            elif self.isValid(sRemain):
          331  +                oSuggResult.addSugg(sNewWord+" "+sRemain)
   330    332           if nDist > oSuggResult.nDistLimit:
   331    333               return
   332    334           cCurrent = sRemain[0:1]
   333    335           for cChar, jAddr in self._getCharArcs(iAddr):
   334    336               if cChar in cp.d1to1.get(cCurrent, cCurrent):
   335    337                   self._suggest(oSuggResult, sRemain[1:], nMaxSwitch, nMaxDel, nMaxHardRepl, nMaxJump, nDist, nDeep+1, jAddr, sNewWord+cChar)
   336    338               elif not bAvoidLoop: