Overview
Comment: | [core] ibdawg: suggestion mechanism > split word function |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | core |
Files: | files | file ages | folders |
SHA3-256: |
388e8809cf91bc6ada30a3c24d23e8c1 |
User & Date: | olr on 2017-10-25 09:41:56 |
Other Links: | manifest | tags |
Context
2017-10-25
| ||
11:37 | [core] ibdawg: clean words before damerau-levenshtein comparison check-in: 1329ae8f1c user: olr tags: trunk, core | |
09:41 | [core] ibdawg: suggestion mechanism > split word function check-in: 388e8809cf user: olr tags: trunk, core | |
2017-10-24
| ||
22:24 | [core] ibdawg: suggestion mechanism > exclude some suffixes (ß) check-in: 5fbb7ec853 user: olr tags: trunk, core | |
Changes
Modified gc_core/js/char_player.js from [56bb998588] to [c0ed55106f].
︙ | |||
314 315 316 317 318 319 320 | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | - + - - - - - + + + + + + + + + - - + + + + - + | ["on", ["ons", "ont"]], ["ON", ["ONS", "ONT"]], ["oi", ["ois", "oit", "oix"]], ["OI", ["OIS", "OIT", "OIX"]], ]), |
Modified gc_core/js/ibdawg.js from [f9dd570de6] to [c871817c8f].
︙ | |||
186 187 188 189 190 191 192 | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | - + - - - + + - - - - | } } return l; } suggest (sWord, nMaxSugg=10) { // returns a array of suggestions for <sWord> |
︙ | |||
216 217 218 219 220 221 222 | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | - + - + | if (sWord.gl_isTitle()) { aSugg = aSugg.map((sSugg) => { return sSugg.gl_toCapitalize(); }); } let dDistTemp = new Map(); aSugg.forEach((sSugg) => { dDistTemp.set(sSugg, char_player.distanceDamerauLevenshtein(sWord, sSugg)); }); aSugg = aSugg.sort((sA, sB) => { return dDistTemp.get(sA) - dDistTemp.get(sB); }).slice(0, nMaxSugg); dDistTemp.clear(); |
︙ |
Modified gc_core/py/char_player.py from [e5dd8880c3] to [2ac4c0eb20].
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 12 | + + | # list of similar chars # useful for suggestion mechanism import re def distanceDamerauLevenshtein (s1, s2): "distance of Damerau-Levenshtein between <s1> and <s2>" # https://fr.wikipedia.org/wiki/Distance_de_Damerau-Levenshtein d = {} nLen1 = len(s1) nLen2 = len(s2) |
︙ | |||
296 297 298 299 300 301 302 | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | - + - - - + + + + + + + + + + + + + + + + | "on": ("ons", "ont"), "ON": ("ONS", "ONT"), "oi": ("ois", "oit", "oix"), "OI": ("OIS", "OIT", "OIX"), } |
Modified gc_core/py/ibdawg.py from [f31919afcb] to [e132c3a736].
︙ | |||
185 186 187 188 189 190 191 | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | - - + - - - - - + - + - + | l.extend(self.morph(sWord.lower())) if sWord.isupper() and len(sWord) > 1: l.extend(self.morph(sWord.capitalize())) return l def suggest (self, sWord, nMaxSugg=10): "returns a set of suggestions for <sWord>" |
︙ |