Overview
Comment: | [graphspell][fx][js] add default suggestions module |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fx | graphspell |
Files: | files | file ages | folders |
SHA3-256: |
c3cdee9c769a05f7377df3f82b8d38b3 |
User & Date: | olr on 2019-05-14 12:58:22 |
Other Links: | manifest | tags |
Context
2019-05-14
| ||
13:27 | [core][fr][misc] change immunity tag (% -> !) check-in: d167d2a710 user: olr tags: trunk, fr, core, misc | |
12:58 | [graphspell][fx][js] add default suggestions module check-in: c3cdee9c76 user: olr tags: trunk, fx, graphspell | |
12:23 | [graphspell] suggestions for French language: add words with apostrophes when it seems relevant check-in: a9c5ccc29c user: olr tags: trunk, fr | |
Changes
Modified gc_lang/fr/webext/gce_worker.js from [107e6c6733] to [8b5d51f7e1].
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | //console.log("[Worker] GC Engine Worker [start]"); //console.log(self); importScripts("grammalecte/graphspell/helpers.js"); importScripts("grammalecte/graphspell/str_transform.js"); importScripts("grammalecte/graphspell/char_player.js"); importScripts("grammalecte/graphspell/ibdawg.js"); importScripts("grammalecte/graphspell/spellchecker.js"); importScripts("grammalecte/text.js"); importScripts("grammalecte/graphspell/tokenizer.js"); importScripts("grammalecte/fr/conj.js"); importScripts("grammalecte/fr/mfsp.js"); importScripts("grammalecte/fr/phonet.js"); | > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | //console.log("[Worker] GC Engine Worker [start]"); //console.log(self); importScripts("grammalecte/graphspell/helpers.js"); importScripts("grammalecte/graphspell/str_transform.js"); importScripts("grammalecte/graphspell/char_player.js"); importScripts("grammalecte/graphspell/suggest.js"); importScripts("grammalecte/graphspell/ibdawg.js"); importScripts("grammalecte/graphspell/spellchecker.js"); importScripts("grammalecte/text.js"); importScripts("grammalecte/graphspell/tokenizer.js"); importScripts("grammalecte/fr/conj.js"); importScripts("grammalecte/fr/mfsp.js"); importScripts("grammalecte/fr/phonet.js"); |
︙ | ︙ |
Modified graphspell-js/spellchecker.js from [29bf30d9e3] to [79840617ea].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* global require, exports, console, IBDAWG, Tokenizer */ "use strict"; if(typeof(process) !== 'undefined') { var ibdawg = require("./ibdawg.js"); var tokenizer = require("./tokenizer.js"); } else if (typeof(require) !== 'undefined') { var ibdawg = require("resource://grammalecte/graphspell/ibdawg.js"); var tokenizer = require("resource://grammalecte/graphspell/tokenizer.js"); } ${map} const dDefaultDictionaries = new Map([ ["fr", "fr-allvars.json"], | > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* global require, exports, console, IBDAWG, Tokenizer */ "use strict"; if(typeof(process) !== 'undefined') { var ibdawg = require("./ibdawg.js"); var tokenizer = require("./tokenizer.js"); var suggest = require("./suggest.js"); } else if (typeof(require) !== 'undefined') { var ibdawg = require("resource://grammalecte/graphspell/ibdawg.js"); var tokenizer = require("resource://grammalecte/graphspell/tokenizer.js"); var suggest = require("resource://grammalecte/graphspell/suggest.js"); } ${map} const dDefaultDictionaries = new Map([ ["fr", "fr-allvars.json"], |
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | } this.oMainDic = this._loadDictionary(mainDic, sPath, true); this.oCommunityDic = this._loadDictionary(communityDic, sPath); this.oPersonalDic = this._loadDictionary(personalDic, sPath); this.bCommunityDic = Boolean(this.oCommunityDic); this.bPersonalDic = Boolean(this.oPersonalDic); this.oTokenizer = null; // storage this.bStorage = false; this._dMorphologies = new Map(); // key: flexion, value: list of morphologies this._dLemmas = new Map(); // key: flexion, value: list of lemmas } _loadDictionary (dictionary, sPath="", bNecessary=false) { | > > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | } this.oMainDic = this._loadDictionary(mainDic, sPath, true); this.oCommunityDic = this._loadDictionary(communityDic, sPath); this.oPersonalDic = this._loadDictionary(personalDic, sPath); this.bCommunityDic = Boolean(this.oCommunityDic); this.bPersonalDic = Boolean(this.oPersonalDic); this.oTokenizer = null; // Default suggestions this.oDefaultSugg = null; this.loadSuggestions(sLangCode) // storage this.bStorage = false; this._dMorphologies = new Map(); // key: flexion, value: list of morphologies this._dLemmas = new Map(); // key: flexion, value: list of lemmas } _loadDictionary (dictionary, sPath="", bNecessary=false) { |
︙ | ︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | this.bCommunityDic = false; } deactivatePersonalDictionary () { this.bPersonalDic = false; } // Storage activateStorage () { this.bStorage = true; } | > > > > > > > > > > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | this.bCommunityDic = false; } deactivatePersonalDictionary () { this.bPersonalDic = false; } // Default suggestions loadSuggestions (sLangCode) { // load default suggestion module for <sLangCode> // When “import” works everywhere, do like with Python if (suggest && suggest.hasOwnProperty(sLangCode)) { this.oDefaultSugg = suggest[sLangCode]; } } // Storage activateStorage () { this.bStorage = true; } |
︙ | ︙ | |||
229 230 231 232 233 234 235 | return this._dLemmas.get(sWord); } return Array.from(new Set(this.getMorph(sWord).map((sMorph) => { return sMorph.slice(1, sMorph.indexOf("/")); }))); } * suggest (sWord, nSuggLimit=10) { // generator: returns 1, 2 or 3 lists of suggestions | > > > > > > > | > > > > | 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 | return this._dLemmas.get(sWord); } return Array.from(new Set(this.getMorph(sWord).map((sMorph) => { return sMorph.slice(1, sMorph.indexOf("/")); }))); } * suggest (sWord, nSuggLimit=10) { // generator: returns 1, 2 or 3 lists of suggestions if (this.oDefaultSugg) { if (this.oDefaultSugg.hasOwnProperty(sWord)) { yield this.oDefaultSugg[sWord].split("|"); } else if (sWord.gl_isTitle() && this.oDefaultSugg.hasOwnProperty(sWord.lower())) { let lRes = this.oDefaultSugg[sWord.toLowerCase()].split("|"); yield lRes.map((sSugg) => { return sSugg.slice(0,1).toUpperCase() + sSugg.slice(1); }); } else { yield this.oMainDic.suggest(sWord, nSuggLimit, true); } } else { yield this.oMainDic.suggest(sWord, nSuggLimit, true); } if (this.bCommunityDic) { yield this.oCommunityDic.suggest(sWord, Math.floor(nSuggLimit/2)+1); } if (this.bPersonalDic) { yield this.oPersonalDic.suggest(sWord, Math.floor(nSuggLimit/2)+1); } } |
︙ | ︙ |
Added graphspell-js/suggest.js version [c30d93f1aa].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | // JavaScript "use strict"; var suggest = { "fr": { "bcp": "beaucoup", "ca": "ça", "cad": "c’est-à-dire", "cb": "combien|CB", "cdlt": "cordialement", "construirent": "construire|construisirent|construisent|construiront", "càd": "c’est-à-dire", "dc": "de|donc", "done": "donc|donne", "email": "courriel|e-mail|émail", "emails": "courriels|e-mails", "Etes-vous": "Êtes-vous", "Etiez-vous": "Étiez-vous", "Etions-nous": "Étions-nous", "parce-que": "parce que", "pcq": "parce que", "pd": "pendant|pédé", "pdq": "pendant que", "pdt": "pendant", "pdtq": "pendant que", "pk": "pourquoi", "pq": "pourquoi|PQ", "prq": "presque", "prsq": "presque", "qcq": "quiconque", "qq": "quelque", "qqch": "quelque chose", "qqn": "quelqu’un", "qqne": "quelqu’une", "qqs": "quelques", "qqunes": "quelques-unes", "qquns": "quelques-uns", "tdq": "tandis que", "tj": "toujours", "tjs": "toujours", "tq": "tant que|tandis que", "ts": "tous", "tt": "tant|tout", "tte": "toute", "ttes": "toutes" } } |
Modified graphspell/fr.py from [963bf7ea5b] to [cc9153951f].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | """ Default suggestion for French language """ dSugg = { "bcp": "beaucoup", "ca": "ça", "cad": "c’est-à-dire", "cb": "combien|CB", "cdlt": "cordialement", "construirent": "construire|construisirent|construisent|construiront", "càd": "c’est-à-dire", "dc": "de|donc", "email": "courriel|e-mail|émail", "emails": "courriels|e-mails", "Etes-vous": "Êtes-vous", "Etiez-vous": "Étiez-vous", "Etions-nous": "Étions-nous", "parce-que": "parce que", | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | """ Default suggestion for French language """ dSugg = { "bcp": "beaucoup", "ca": "ça", "cad": "c’est-à-dire", "cb": "combien|CB", "cdlt": "cordialement", "construirent": "construire|construisirent|construisent|construiront", "càd": "c’est-à-dire", "done": "donc|donne", "dc": "de|donc", "email": "courriel|e-mail|émail", "emails": "courriels|e-mails", "Etes-vous": "Êtes-vous", "Etiez-vous": "Étiez-vous", "Etions-nous": "Étions-nous", "parce-que": "parce que", |
︙ | ︙ |