Overview
Comment: | [core] ibdawg: another suggestion method |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core | spellsugg |
Files: | files | file ages | folders |
SHA3-256: |
1edae62ad8b792d29eba111b042aee28 |
User & Date: | olr on 2017-11-07 11:56:37 |
Other Links: | branch diff | manifest | tags |
Context
2017-11-07
| ||
17:03 | [core] ibdawg: use SuggResult object + code cleaning check-in: 6c8c1776f5 user: olr tags: core, spellsugg | |
11:56 | [core] ibdawg: another suggestion method check-in: 1edae62ad8 user: olr tags: core, spellsugg | |
2017-11-06
| ||
17:21 | [core][py] timer for testing check-in: 8ddc15536e user: olr tags: trunk, core | |
Changes
Modified cli.py from [ed7458a4d3] to [a5ccfdebb3].
︙ | |||
206 207 208 209 210 211 212 213 214 215 216 217 218 219 | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | + | echo("* " + sWord) for sMorph in oDict.getMorph(sWord): echo(" {:<32} {}".format(sMorph, oLexGraphe.formatTags(sMorph))) elif sText.startswith("!"): for sWord in sText[1:].strip().split(): if sWord: echo(" | ".join(oDict.suggest(sWord))) echo(" | ".join(oDict.suggest2(sWord))) elif sText.startswith(">"): oDict.drawPath(sText[1:].strip()) elif sText.startswith("="): for sRes in oDict.select(sText[1:].strip()): echo(sRes) elif sText.startswith("/+ "): gce.setOptions({ opt:True for opt in sText[3:].strip().split() if opt in gce.getOptions() }) |
︙ |
Modified gc_core/py/char_player.py from [97f69bd70d] to [19df5311c8].
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | def showDistance (s1, s2): s1b = cleanWord(s1); s2b = cleanWord(s2); print(f"Distance: {s1} / {s2} = {distanceDamerauLevenshtein(s1, s2)}") print(f"Distance: {s1b} / {s2b} = {distanceDamerauLevenshtein(s1b, s2b)}") def distanceSift4 (s1, s2, nMaxOffset=5): "implementation of general Sift4." # https://siderite.blogspot.com/2014/11/super-fast-and-accurate-string-distance.html if not s1: return len(s2) if not s2: return len(s1) nLen1, nLen2 = len(s1), len(s2) i1, i2 = 0, 0 # Cursors for each string nLargestCS = 0 # Largest common substring nLocalCS = 0 # Local common substring nTrans = 0 # Number of transpositions ('ab' vs 'ba') lOffset = [] # Offset pair array, for computing the transpositions while i1 < nLen1 and i2 < nLen2: if s1[i1] == s2[i2]: nLocalCS += 1 # Check if current match is a transposition bTrans = False i = 0 while i < len(lOffset): t = lOffset[i] if i1 <= t[0] or i2 <= t[1]: bTrans = abs(i2-i1) >= abs(t[1] - t[0]) if bTrans: nTrans += 1 elif not t[2]: t[2] = True nTrans += 1 break elif i1 > t[1] and i2 > t[0]: del lOffset[i] else: i += 1 lOffset.append([i1, i2, bTrans]) else: nLargestCS += nLocalCS nLocalCS = 0 if i1 != i2: i1 = i2 = min(i1, i2) for i in range(nMaxOffset): if i1 + i >= nLen1 and i2 + i >= nLen2: break elif i1 + i < nLen1 and s1[i1+i] == s2[i2]: i1 += i - 1 i2 -= 1 break elif i2 + i < nLen2 and s1[i1] == s2[i2+i]: i2 += i - 1 i1 -= 1 break i1 += 1 i2 += 1 if i1 >= nLen1 or i2 >= nLen2: nLargestCS += nLocalCS nLocalCS = 0 i1 = i2 = min(i1, i2) nLargestCS += nLocalCS return round(max(nLen1, nLen2) - nLargestCS + nTrans) # Method: Remove Useless Chars _dVovels = { 'a': '', 'e': '', 'i': '', 'o': '', 'u': '', 'y': '', 'à': '', 'é': '', 'î': '', 'ô': '', 'û': '', 'ÿ': '', 'â': '', 'è': '', 'ï': '', 'ö': '', 'ù': '', 'ŷ': '', |
︙ |
Modified gc_core/py/ibdawg.py from [a0b40e49a1] to [b7c1b974f3].
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | - - + + | #!python3 import os import traceback import pkgutil import re from itertools import chain from functools import wraps import time |
︙ | |||
216 217 218 219 220 221 222 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | sCleanWord = cp.cleanWord(sWord) aSugg = sorted(aSugg, key=lambda sSugg: cp.distanceDamerauLevenshtein(sCleanWord, cp.cleanWord(sSugg)))[:nMaxSugg] if sSfx or sPfx: # we add what we removed return list(map(lambda sSug: sPfx + sSug + sSfx, aSugg)) return aSugg |
︙ |