Index: compile_rules.py ================================================================== --- compile_rules.py +++ compile_rules.py @@ -79,18 +79,18 @@ sCode = sCode.replace(".endswith", ".endsWith") sCode = sCode.replace(".find", ".indexOf") sCode = sCode.replace(".startswith", ".startsWith") sCode = sCode.replace(".lower", ".toLowerCase") sCode = sCode.replace(".upper", ".toUpperCase") - sCode = sCode.replace(".isdigit", "._isDigit") - sCode = sCode.replace(".isupper", "._isUpperCase") - sCode = sCode.replace(".islower", "._isLowerCase") - sCode = sCode.replace(".istitle", "._isTitle") - sCode = sCode.replace(".capitalize", "._toCapitalize") - sCode = sCode.replace(".strip", "._trim") - sCode = sCode.replace(".lstrip", "._trimLeft") - sCode = sCode.replace(".rstrip", "._trimRight") + sCode = sCode.replace(".isdigit", ".gl_isDigit") + sCode = sCode.replace(".isupper", ".gl_isUpperCase") + sCode = sCode.replace(".islower", ".gl_isLowerCase") + sCode = sCode.replace(".istitle", ".gl_isTitle") + sCode = sCode.replace(".capitalize", ".gl_toCapitalize") + sCode = sCode.replace(".strip", ".gl_trim") + sCode = sCode.replace(".lstrip", ".gl_trimLeft") + sCode = sCode.replace(".rstrip", ".gl_trimRight") sCode = sCode.replace('.replace("."', ".replace(/\./g") sCode = sCode.replace('.replace("..."', ".replace(/\.\.\./g") sCode = re.sub('.replace\("([^"]+)" ?,', ".replace(/\\1/g,", sCode) # regex sCode = re.sub('re.search\("([^"]+)", *(m.group\(\\d\))\)', "(\\2.search(/\\1/) >= 0)", sCode) Index: gc_core/js/ibdawg.js ================================================================== --- gc_core/js/ibdawg.js +++ gc_core/js/ibdawg.js @@ -87,11 +87,11 @@ // checks if sToken is valid (if there is hyphens in sToken, sToken is split, each part is checked) if (this.isValid(sToken)) { return true; } if (sToken.includes("-")) { - if (sToken._count("-") > 4) { + if (sToken.gl_count("-") > 4) { return true; } return sToken.split("-").every(sWord => this.isValid(sWord)); } return false; @@ -106,20 +106,20 @@ sWord = sWord.replace("’", "'"); } if (this.lookup(sWord)) { return true; } - if (sWord.charAt(0)._isUpperCase()) { + if (sWord.charAt(0).gl_isUpperCase()) { if (sWord.length > 1) { - if (sWord._isTitle()) { + if (sWord.gl_isTitle()) { return !!this.lookup(sWord.toLowerCase()); } - if (sWord._isUpperCase()) { + if (sWord.gl_isUpperCase()) { if (this.bOptNumSigle) { return true; } - return !!(this.lookup(sWord.toLowerCase()) || this.lookup(sWord._toCapitalize())); + return !!(this.lookup(sWord.toLowerCase()) || this.lookup(sWord.gl_toCapitalize())); } return !!this.lookup(sWord.slice(0, 1).toLowerCase() + sWord.slice(1)); } else { return !!this.lookup(sWord.toLowerCase()); } @@ -154,14 +154,14 @@ }; getMorph (sWord) { // retrieves morphologies list, different casing allowed let l = this.morph(sWord); - if (sWord[0]._isUpperCase()) { + if (sWord[0].gl_isUpperCase()) { l = l.concat(this.morph(sWord.toLowerCase())); - if (sWord._isUpperCase() && sWord.length > 1) { - l = l.concat(this.morph(sWord._toCapitalize())); + if (sWord.gl_isUpperCase() && sWord.length > 1) { + l = l.concat(this.morph(sWord.gl_toCapitalize())); } } return l; }; Index: gc_core/js/jsex_map.js ================================================================== --- gc_core/js/jsex_map.js +++ gc_core/js/jsex_map.js @@ -1,26 +1,26 @@ // Map -if (Map.prototype.__grammalecte__ === undefined) { - Map.prototype._shallowCopy = function () { +if (Map.prototype.grammalecte === undefined) { + Map.prototype.gl_shallowCopy = function () { let oNewMap = new Map(); for (let [key, val] of this.entries()) { oNewMap.set(key, val); } return oNewMap; } - Map.prototype._get = function (key, defaultValue) { + Map.prototype.gl_get = function (key, defaultValue) { let res = this.get(key); if (res !== undefined) { return res; } return defaultValue; } - Map.prototype._toString = function () { + Map.prototype.gl_toString = function () { // Default .toString() gives nothing useful let sRes = "{ "; for (let [k, v] of this.entries()) { sRes += (typeof k === "string") ? '"' + k + '": ' : k.toString() + ": "; sRes += (typeof v === "string") ? '"' + v + '", ' : v.toString() + ", "; @@ -27,21 +27,21 @@ } sRes = sRes.slice(0, -2) + " }" return sRes; } - Map.prototype._update = function (dDict) { + Map.prototype.gl_update = function (dDict) { for (let [k, v] of dDict.entries()) { this.set(k, v); } } - Map.prototype._updateOnlyExistingKeys = function (dDict) { + Map.prototype.gl_updateOnlyExistingKeys = function (dDict) { for (let [k, v] of dDict.entries()) { if (this.has(k)){ this.set(k, v); } } } - Map.prototype.__grammalecte__ = true; + Map.prototype.grammalecte = true; } Index: gc_core/js/jsex_regex.js ================================================================== --- gc_core/js/jsex_regex.js +++ gc_core/js/jsex_regex.js @@ -1,10 +1,10 @@ // regex -if (RegExp.prototype.__grammalecte__ === undefined) { - RegExp.prototype._exec2 = function (sText, aGroupsPos, aNegLookBefore=null) { +if (RegExp.prototype.grammalecte === undefined) { + RegExp.prototype.gl_exec2 = function (sText, aGroupsPos, aNegLookBefore=null) { let m; while ((m = this.exec(sText)) !== null) { // we have to iterate over sText here too // because first match doesn’t imply it’s a valid match according to negative lookbefore assertions, // and even if first match is finally invalid, it doesn’t mean the following eligible matchs would be invalid too. @@ -74,7 +74,7 @@ } } return m; } - RegExp.prototype.__grammalecte__ = true; + RegExp.prototype.grammalecte = true; } Index: gc_core/js/jsex_string.js ================================================================== --- gc_core/js/jsex_string.js +++ gc_core/js/jsex_string.js @@ -1,10 +1,10 @@ // String -if (String.prototype.__grammalecte__ === undefined) { - String.prototype._count = function (sSearch, bOverlapping) { +if (String.prototype.grammalecte === undefined) { + String.prototype.gl_count = function (sSearch, bOverlapping) { // http://jsperf.com/string-ocurrence-split-vs-match/8 if (sSearch.length <= 0) { return this.length + 1; } let nOccur = 0; @@ -14,44 +14,44 @@ nOccur++; iPos += nStep; } return nOccur; } - String.prototype._isDigit = function () { + String.prototype.gl_isDigit = function () { return (this.search(/^[0-9⁰¹²³⁴⁵⁶⁷⁸⁹]+$/) !== -1); } - String.prototype._isLowerCase = function () { + String.prototype.gl_isLowerCase = function () { return (this.search(/^[a-zà-öø-ÿ0-9-]+$/) !== -1); } - String.prototype._isUpperCase = function () { + String.prototype.gl_isUpperCase = function () { return (this.search(/^[A-ZÀ-ÖØ-ߌ0-9-]+$/) !== -1); } - String.prototype._isTitle = function () { + String.prototype.gl_isTitle = function () { return (this.search(/^[A-ZÀ-ÖØ-ߌ][a-zà-öø-ÿ'’-]+$/) !== -1); } - String.prototype._toCapitalize = function () { + String.prototype.gl_toCapitalize = function () { return this.slice(0,1).toUpperCase() + this.slice(1).toLowerCase(); } - String.prototype._expand = function (oMatch) { + String.prototype.gl_expand = function (oMatch) { let sNew = this; for (let i = 0; i < oMatch.length ; i++) { let z = new RegExp("\\\\"+parseInt(i), "g"); sNew = sNew.replace(z, oMatch[i]); } return sNew; } - String.prototype._trimRight = function (sChars) { + String.prototype.gl_trimRight = function (sChars) { let z = new RegExp("["+sChars+"]+$"); return this.replace(z, ""); } - String.prototype._trimLeft = function (sChars) { + String.prototype.gl_trimLeft = function (sChars) { let z = new RegExp("^["+sChars+"]+"); return this.replace(z, ""); } - String.prototype._trim = function (sChars) { + String.prototype.gl_trim = function (sChars) { let z1 = new RegExp("^["+sChars+"]+"); let z2 = new RegExp("["+sChars+"]+$"); return this.replace(z1, "").replace(z2, ""); } - String.prototype.__grammalecte__ = true; + String.prototype.grammalecte = true; } Index: gc_core/js/lang_core/gc_engine.js ================================================================== --- gc_core/js/lang_core/gc_engine.js +++ gc_core/js/lang_core/gc_engine.js @@ -7,11 +7,11 @@ function capitalizeArray (aArray) { // can’t map on user defined function?? let aNew = []; for (let i = 0; i < aArray.length; i = i + 1) { - aNew[i] = aArray[i]._toCapitalize(); + aNew[i] = aArray[i].gl_toCapitalize(); } return aNew; } const ibdawg = require("resource://grammalecte/ibdawg.js"); @@ -84,11 +84,11 @@ if (4 < (iEnd - iStart) < 2000) { dDA.clear(); //echo(sText.slice(iStart, iEnd)); try { [_, errs] = _proofread(sText.slice(iStart, iEnd), sAlt.slice(iStart, iEnd), iStart, false, dDA, dPriority, sCountry, bDebug, bContext); - dErrors._update(errs); + dErrors.gl_update(errs); } catch (e) { helpers.logerror(e); } } @@ -116,11 +116,11 @@ for (let [sOption, lRuleGroup] of _getRules(bParagraph)) { if (!sOption || option(sOption)) { for (let [zRegex, bUppercase, sLineId, sRuleId, nPriority, lActions, lGroups, lNegLookBefore] of lRuleGroup) { if (!_aIgnoredRules.has(sRuleId)) { - while ((m = zRegex._exec2(s, lGroups, lNegLookBefore)) !== null) { + while ((m = zRegex.gl_exec2(s, lGroups, lNegLookBefore)) !== null) { bCondMemo = null; /*if (bDebug) { echo(">>>> Rule # " + sLineId + " - Text: " + s + " opt: "+ sOption); }*/ for (let [sFuncCond, cActionType, sWhat, ...eAct] of lActions) { @@ -151,11 +151,11 @@ case "=": // disambiguation //echo("-> disambiguation by " + sLineId + "\nzRegex: " + zRegex.source); oEvalFunc[sWhat](s, m, dDA); if (bDebug) { - echo("= " + m[0] + " # " + sLineId + "\nDA: " + dDA._toString()); + echo("= " + m[0] + " # " + sLineId + "\nDA: " + dDA.gl_toString()); } break; case ">": // we do nothing, this test is just a condition to apply all following actions break; @@ -194,11 +194,11 @@ oErr["sType"] = (sOption) ? sOption : "notype"; // suggestions if (sRepl[0] === "=") { let sugg = oEvalFunc[sRepl.slice(1)](s, m); if (sugg) { - if (bUppercase && m[iGroup].slice(0,1)._isUpperCase()) { + if (bUppercase && m[iGroup].slice(0,1).gl_isUpperCase()) { oErr["aSuggestions"] = capitalizeArray(sugg.split("|")); } else { oErr["aSuggestions"] = sugg.split("|"); } } else { @@ -205,21 +205,21 @@ oErr["aSuggestions"] = []; } } else if (sRepl == "_") { oErr["aSuggestions"] = []; } else { - if (bUppercase && m[iGroup].slice(0,1)._isUpperCase()) { - oErr["aSuggestions"] = capitalizeArray(sRepl._expand(m).split("|")); + if (bUppercase && m[iGroup].slice(0,1).gl_isUpperCase()) { + oErr["aSuggestions"] = capitalizeArray(sRepl.gl_expand(m).split("|")); } else { - oErr["aSuggestions"] = sRepl._expand(m).split("|"); + oErr["aSuggestions"] = sRepl.gl_expand(m).split("|"); } } // Message if (sMsg[0] === "=") { sMessage = oEvalFunc[sMsg.slice(1)](s, m) } else { - sMessage = sMsg._expand(m); + sMessage = sMsg.gl_expand(m); } if (bIdRule) { sMessage += " ##" + sLineId + " #" + sRuleId; } oErr["sMessage"] = sMessage; @@ -245,15 +245,15 @@ } else if (sRepl === "@") { sNew = "@".repeat(ln); } else if (sRepl.slice(0,1) === "=") { sNew = oEvalFunc[sRepl.slice(1)](s, m); sNew = sNew + " ".repeat(ln-sNew.length); - if (bUppercase && m[iGroup].slice(0,1)._isUpperCase()) { - sNew = sNew._toCapitalize(); + if (bUppercase && m[iGroup].slice(0,1).gl_isUpperCase()) { + sNew = sNew.gl_toCapitalize(); } } else { - sNew = sRepl._expand(m); + sNew = sRepl.gl_expand(m); sNew = sNew + " ".repeat(ln-sNew.length); } //echo("\n"+s+"\nstart: "+m.start[iGroup]+" end:"+m.end[iGroup]) return s.slice(0, m.start[iGroup]) + sNew + s.slice(m.end[iGroup]); } @@ -298,11 +298,11 @@ function load (sContext="JavaScript") { try { _oDict = new ibdawg.IBDAWG("${dic_name}.json"); _sContext = sContext; - _dOptions = gc_options.getOptions(sContext)._shallowCopy(); // duplication necessary, to be able to reset to default + _dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default } catch (e) { helpers.logerror(e); } } @@ -312,23 +312,23 @@ _dOptions.set(sOpt, bVal); } } function setOptions (dOpt) { - _dOptions._updateOnlyExistingKeys(dOpt); + _dOptions.gl_updateOnlyExistingKeys(dOpt); } function getOptions () { return _dOptions; } function getDefaultOptions () { - return gc_options.getOptions(_sContext)._shallowCopy(); + return gc_options.getOptions(_sContext).gl_shallowCopy(); } function resetOptions () { - _dOptions = gc_options.getOptions(_sContext)._shallowCopy(); + _dOptions = gc_options.getOptions(_sContext).gl_shallowCopy(); } function getDictionary () { return _oDict; } @@ -518,11 +518,11 @@ return false; } function look_chk1 (dDA, s, nOffset, zPattern, sPatternGroup1, sNegPatternGroup1=null) { // returns True if s has pattern zPattern and m.group(1) has pattern sPatternGroup1 - let m = zPattern._exec2(s, null); + let m = zPattern.gl_exec2(s, null); if (!m) { return false; } try { let sWord = m[1]; Index: gc_lang/fr/modules-js/conj.js ================================================================== --- gc_lang/fr/modules-js/conj.js +++ gc_lang/fr/modules-js/conj.js @@ -380,11 +380,11 @@ conjugue (sTemps, sWho, bPro, bNeg, bTpsCo, bInt, bFem) { if (!this.dConj.get(sTemps).get(sWho)) { return ""; } let sConj; - if (!bTpsCo && bInt && sWho == ":1s" && this.dConj.get(sTemps)._get(":1ś", false)) { + if (!bTpsCo && bInt && sWho == ":1s" && this.dConj.get(sTemps).gl_get(":1ś", false)) { sWho = ":1ś"; } if (bTpsCo) { sConj = (!bPro) ? _getConjWithTags(this.sVerbAux, this._tTagsAux, sTemps, sWho) : getConj("être", sTemps, sWho); } else { Index: gc_lang/fr/modules-js/gce_analyseur.js ================================================================== --- gc_lang/fr/modules-js/gce_analyseur.js +++ gc_lang/fr/modules-js/gce_analyseur.js @@ -20,11 +20,11 @@ if (s2 == "eux") { return "ils"; } if (s2 == "elle" || s2 == "elles") { // We don’t check if word exists in _dAnalyses, for it is assumed it has been done before - if (cr.mbNprMasNotFem(_dAnalyses._get(s1, ""))) { + if (cr.mbNprMasNotFem(_dAnalyses.gl_get(s1, ""))) { return "ils"; } // si épicène, indéterminable, mais OSEF, le féminin l’emporte return "elles"; } @@ -32,39 +32,39 @@ } function apposition (sWord1, sWord2) { // returns true if nom + nom (no agreement required) // We don’t check if word exists in _dAnalyses, for it is assumed it has been done before - return cr.mbNomNotAdj(_dAnalyses._get(sWord2, "")) && cr.mbPpasNomNotAdj(_dAnalyses._get(sWord1, "")); + return cr.mbNomNotAdj(_dAnalyses.gl_get(sWord2, "")) && cr.mbPpasNomNotAdj(_dAnalyses.gl_get(sWord1, "")); } function isAmbiguousNAV (sWord) { // words which are nom|adj and verb are ambiguous (except être and avoir) if (!_dAnalyses.has(sWord) && !_storeMorphFromFSA(sWord)) { return false; } - if (!cr.mbNomAdj(_dAnalyses._get(sWord, "")) || sWord == "est") { + if (!cr.mbNomAdj(_dAnalyses.gl_get(sWord, "")) || sWord == "est") { return false; } - if (cr.mbVconj(_dAnalyses._get(sWord, "")) && !cr.mbMG(_dAnalyses._get(sWord, ""))) { + if (cr.mbVconj(_dAnalyses.gl_get(sWord, "")) && !cr.mbMG(_dAnalyses.gl_get(sWord, ""))) { return true; } return false; } function isAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj) { //// use it if sWord1 won’t be a verb; word2 is assumed to be true via isAmbiguousNAV // We don’t check if word exists in _dAnalyses, for it is assumed it has been done before - let a2 = _dAnalyses._get(sWord2, null); + let a2 = _dAnalyses.gl_get(sWord2, null); if (!a2 || a2.length === 0) { return false; } if (cr.checkConjVerb(a2, sReqMorphConj)) { // verb word2 is ok return false; } - let a1 = _dAnalyses._get(sWord1, null); + let a1 = _dAnalyses.gl_get(sWord1, null); if (!a1 || a1.length === 0) { return false; } if (cr.checkAgreement(a1, a2) && (cr.mbAdj(a2) || cr.mbAdj(a1))) { return false; @@ -73,19 +73,19 @@ } function isVeryAmbiguousAndWrong (sWord1, sWord2, sReqMorphNA, sReqMorphConj, bLastHopeCond) { //// use it if sWord1 can be also a verb; word2 is assumed to be true via isAmbiguousNAV // We don’t check if word exists in _dAnalyses, for it is assumed it has been done before - let a2 = _dAnalyses._get(sWord2, null) + let a2 = _dAnalyses.gl_get(sWord2, null) if (!a2 || a2.length === 0) { return false; } if (cr.checkConjVerb(a2, sReqMorphConj)) { // verb word2 is ok return false; } - let a1 = _dAnalyses._get(sWord1, null); + let a1 = _dAnalyses.gl_get(sWord1, null); if (!a1 || a1.length === 0) { return false; } if (cr.checkAgreement(a1, a2) && (cr.mbAdj(a2) || cr.mbAdjNb(a1))) { return false; @@ -101,15 +101,15 @@ return false; } function checkAgreement (sWord1, sWord2) { // We don’t check if word exists in _dAnalyses, for it is assumed it has been done before - let a2 = _dAnalyses._get(sWord2, null) + let a2 = _dAnalyses.gl_get(sWord2, null) if (!a2 || a2.length === 0) { return true; } - let a1 = _dAnalyses._get(sWord1, null); + let a1 = _dAnalyses.gl_get(sWord1, null); if (!a1 || a1.length === 0) { return true; } return cr.checkAgreement(a1, a2); } @@ -116,11 +116,11 @@ function mbUnit (s) { if (/[µ\/⁰¹²³⁴⁵⁶⁷⁸⁹Ωℓ·]/.test(s)) { return true; } - if (s.length > 1 && s.length < 16 && s.slice(0, 1)._isLowerCase() && (!s.slice(1)._isLowerCase() || /[0-9]/.test(s))) { + if (s.length > 1 && s.length < 16 && s.slice(0, 1).gl_isLowerCase() && (!s.slice(1).gl_isLowerCase() || /[0-9]/.test(s))) { return true; } return false; } @@ -133,15 +133,15 @@ function isEndOfNG (dDA, s, iOffset) { if (_zEndOfNG1.test(s)) { return true; } - let m = _zEndOfNG2._exec2(s, ["$"]); + let m = _zEndOfNG2.gl_exec2(s, ["$"]); if (m && morphex(dDA, [iOffset+m.start[1], m[1]], ":[VR]", ":[NAQP]")) { return true; } - m = _zEndOfNG3._exec2(s, ["$"]); + m = _zEndOfNG3.gl_exec2(s, ["$"]); if (m && !morph(dDA, [iOffset+m.start[1], m[1]], ":[NA]", false)) { return true; } return false; } @@ -153,11 +153,11 @@ function isNextNotCOD (dDA, s, iOffset) { if (_zNextIsNotCOD1.test(s) || _zNextIsNotCOD2.test(s)) { return true; } - let m = _zNextIsNotCOD3._exec2(s, ["$"]); + let m = _zNextIsNotCOD3.gl_exec2(s, ["$"]); if (m && morphex(dDA, [iOffset+m.start[1], m[1]], ":[123][sp]", ":[DM]")) { return true; } return false; } @@ -168,11 +168,11 @@ function isNextVerb (dDA, s, iOffset) { if (_zNextIsVerb1.test(s)) { return true; } - let m = _zNextIsVerb2._exec2(s, ["$"]); + let m = _zNextIsVerb2.gl_exec2(s, ["$"]); if (m && morph(dDA, [iOffset+m.start[1], m[1]], ":[123][sp]", false)) { return true; } return false; } Index: gc_lang/fr/modules-js/gce_suggestions.js ================================================================== --- gc_lang/fr/modules-js/gce_suggestions.js +++ gc_lang/fr/modules-js/gce_suggestions.js @@ -13,11 +13,11 @@ for (let sStem of stem(sFlex)) { let tTags = conj._getTags(sStem); if (tTags) { // we get the tense let aTense = new Set(); - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { let m; let zVerb = new RegExp (sStem+" .*?(:(?:Y|I[pqsf]|S[pq]|K))", "g"); while (m = zVerb.exec(sMorph)) { // stem must be used in regex to prevent confusion between different verbs (e.g. sauras has 2 stems: savoir and saurer) if (m) { @@ -163,13 +163,13 @@ } else if (cMode.startsWith(":I") || cMode.startsWith(":S")) { lMode = [cMode]; } else { return ""; } - let sWho = _dQuiEst._get(sSuj.toLowerCase(), null); + let sWho = _dQuiEst.gl_get(sSuj.toLowerCase(), null); if (!sWho) { - if (sSuj[0]._isLowerCase()) { // pas un pronom, ni un nom propre + if (sSuj[0].gl_isLowerCase()) { // pas un pronom, ni un nom propre return ""; } sWho = ":3s"; } let aSugg = new Set(); @@ -195,11 +195,11 @@ // returns plural forms assuming sFlex is singular if (sWordToAgree) { if (!_dAnalyses.has(sWordToAgree) && !_storeMorphFromFSA(sWordToAgree)) { return ""; } - let sGender = cr.getGender(_dAnalyses._get(sWordToAgree, [])); + let sGender = cr.getGender(_dAnalyses.gl_get(sWordToAgree, [])); if (sGender == ":m") { return suggMasPlur(sFlex); } else if (sGender == ":f") { return suggFemPlur(sFlex); } @@ -255,11 +255,11 @@ function suggMasSing (sFlex, bSuggSimil=false) { // returns masculine singular forms // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before let aSugg = new Set(); - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (!sMorph.includes(":V")) { // not a verb if (sMorph.includes(":m") || sMorph.includes(":e")) { aSugg.add(suggSing(sFlex)); } else { @@ -291,11 +291,11 @@ function suggMasPlur (sFlex, bSuggSimil=false) { // returns masculine plural forms // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before let aSugg = new Set(); - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (!sMorph.includes(":V")) { // not a verb if (sMorph.includes(":m") || sMorph.includes(":e")) { aSugg.add(suggPlur(sFlex)); } else { @@ -332,11 +332,11 @@ function suggFemSing (sFlex, bSuggSimil=false) { // returns feminine singular forms // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before let aSugg = new Set(); - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (!sMorph.includes(":V")) { // not a verb if (sMorph.includes(":f") || sMorph.includes(":e")) { aSugg.add(suggSing(sFlex)); } else { @@ -366,11 +366,11 @@ function suggFemPlur (sFlex, bSuggSimil=false) { // returns feminine plural forms // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before let aSugg = new Set(); - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (!sMorph.includes(":V")) { // not a verb if (sMorph.includes(":f") || sMorph.includes(":e")) { aSugg.add(suggPlur(sFlex)); } else { @@ -425,11 +425,11 @@ function switchGender (sFlex, bPlur=null) { // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before let aSugg = new Set(); if (bPlur === null) { - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (sMorph.includes(":f")) { if (sMorph.includes(":s")) { aSugg.add(suggMasSing(sFlex)); } else if (sMorph.includes(":p")) { aSugg.add(suggMasPlur(sFlex)); @@ -444,19 +444,19 @@ aSugg.add(suggFemPlur(sFlex)); } } } } else if (bPlur) { - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (sMorph.includes(":f")) { aSugg.add(suggMasPlur(sFlex)); } else if (sMorph.includes(":m")) { aSugg.add(suggFemPlur(sFlex)); } } } else { - for (let sMorph of _dAnalyses._get(sFlex, [])) { + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { if (sMorph.includes(":f")) { aSugg.add(suggMasSing(sFlex)); } else if (sMorph.includes(":m")) { aSugg.add(suggFemSing(sFlex)); } @@ -468,11 +468,11 @@ return ""; } function switchPlural (sFlex) { let aSugg = new Set(); - for (let sMorph of _dAnalyses._get(sFlex, [])) { // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before + for (let sMorph of _dAnalyses.gl_get(sFlex, [])) { // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before if (sMorph.includes(":s")) { aSugg.add(suggPlur(sFlex)); } else if (sMorph.includes(":p")) { aSugg.add(suggSing(sFlex)); } @@ -488,11 +488,11 @@ } function suggSimil (sWord, sPattern) { // return list of words phonetically similar to sWord and whom POS is matching sPattern let aSugg = phonet.selectSimil(sWord, sPattern); - for (let sMorph of _dAnalyses._get(sWord, [])) { + for (let sMorph of _dAnalyses.gl_get(sWord, [])) { for (let e of conj.getSimil(sWord, sMorph, sPattern)) { aSugg.add(e); } } if (aSugg.size > 0) { @@ -511,11 +511,11 @@ return "ce"; } function suggLesLa (sWord) { // we don’t check if word exists in _dAnalyses, for it is assumed it has been done before - if (_dAnalyses._get(sWord, []).some(s => s.includes(":p"))) { + if (_dAnalyses.gl_get(sWord, []).some(s => s.includes(":p"))) { return "les|la"; } return "la"; } Index: gc_lang/fr/modules-js/lexicographe.js ================================================================== --- gc_lang/fr/modules-js/lexicographe.js +++ gc_lang/fr/modules-js/lexicographe.js @@ -206,24 +206,24 @@ // return a list [type, token_string, values] let m = null; try { switch (oToken.sType) { case 'SEPARATOR': - return { sType: oToken.sType, sValue: oToken.sValue, aLabel: [_dSeparator._get(oToken.sValue, "caractère indéterminé")] }; + return { sType: oToken.sType, sValue: oToken.sValue, aLabel: [_dSeparator.gl_get(oToken.sValue, "caractère indéterminé")] }; break; case 'NUM': return { sType: oToken.sType, sValue: oToken.sValue, aLabel: ["nombre"] }; break; case 'LINK': return { sType: oToken.sType, sValue: oToken.sValue.slice(0,40)+"…", aLabel: ["hyperlien"] }; break; case 'ELPFX': let sTemp = oToken.sValue.replace("’", "").replace("'", "").replace("`", "").toLowerCase(); - return { sType: oToken.sType, sValue: oToken.sValue, aLabel: [_dPFX._get(sTemp, "préfixe élidé inconnu")] }; + return { sType: oToken.sType, sValue: oToken.sValue, aLabel: [_dPFX.gl_get(sTemp, "préfixe élidé inconnu")] }; break; case 'WORD': - if (oToken.sValue._count("-") > 4) { + if (oToken.sValue.gl_count("-") > 4) { return { sType: "COMPLEX", sValue: oToken.sValue, aLabel: ["élément complexe indéterminé"] }; } else if (this.oDict.isValidToken(oToken.sValue)) { let lMorph = this.oDict.getMorph(oToken.sValue); let aElem = [ for (s of lMorph) if (s.includes(":")) this._formatTags(s) ]; @@ -264,11 +264,11 @@ if (!sRes) { sRes = "#Erreur. Étiquette inconnue : [" + sTags + "]"; helpers.echo(sRes); return sRes; } - return sRes._trimRight(","); + return sRes.gl_trimRight(","); }; _formatSuffix (s) { if (s.startsWith("t-")) { return "“t” euphonique +" + _dAD.get(s.slice(2)); Index: gc_lang/fr/modules-js/phonet.js ================================================================== --- gc_lang/fr/modules-js/phonet.js +++ gc_lang/fr/modules-js/phonet.js @@ -16,19 +16,19 @@ if (!sWord) { return false; } if (_dWord.has(sWord)) { if (sPattern) { - return getSimil(sWord).some(sSimil => _dMorph._get(sSimil, []).some(sMorph => sMorph.search(sPattern) >= 0)); + return getSimil(sWord).some(sSimil => _dMorph.gl_get(sSimil, []).some(sMorph => sMorph.search(sPattern) >= 0)); } return true; } - if (sWord.slice(0,1)._isUpperCase()) { + if (sWord.slice(0,1).gl_isUpperCase()) { sWord = sWord.toLowerCase(); if (_dWord.has(sWord)) { if (sPattern) { - return getSimil(sWord).some(sSimil => _dMorph._get(sSimil, []).some(sMorph => sMorph.search(sPattern) >= 0)); + return getSimil(sWord).some(sSimil => _dMorph.gl_get(sSimil, []).some(sMorph => sMorph.search(sPattern) >= 0)); } return true; } } return false; @@ -40,11 +40,11 @@ return []; } if (_dWord.has(sWord)) { return _lSet[_dWord.get(sWord)]; } - if (sWord.slice(0,1)._isUpperCase()) { + if (sWord.slice(0,1).gl_isUpperCase()) { sWord = sWord.toLowerCase(); if (_dWord.has(sWord)) { return _lSet[_dWord.get(sWord)]; } } @@ -56,11 +56,11 @@ if (!sPattern) { return new Set(getSimil(sWord)); } let aSelect = new Set(); for (let sSimil of getSimil(sWord)) { - for (let sMorph of _dMorph._get(sSimil, [])) { + for (let sMorph of _dMorph.gl_get(sSimil, [])) { if (sMorph.search(sPattern) >= 0) { aSelect.add(sSimil); } } } Index: gc_lang/fr/modules-js/textformatter.js ================================================================== --- gc_lang/fr/modules-js/textformatter.js +++ gc_lang/fr/modules-js/textformatter.js @@ -249,11 +249,11 @@ ["ma_word", true], ["ma_1letter_lowercase", false], ["ma_1letter_uppercase", false] ]); -const dOptions = dDefaultOptions._shallowCopy(); +const dOptions = dDefaultOptions.gl_shallowCopy(); class TextFormatter { constructor () { @@ -260,11 +260,11 @@ this.sLang = "fr"; }; formatText (sText, dOpt=null) { if (dOpt !== null) { - dOptions._updateOnlyExistingKeys(dOpt); + dOptions.gl_updateOnlyExistingKeys(dOpt); } for (let [sOptName, bVal] of dOptions) { if (bVal && oReplTable.has(sOptName)) { for (let [zRgx, sRep] of oReplTable[sOptName]) { sText = sText.replace(zRgx, sRep); Index: gc_lang/fr/xpi/gce_worker.js ================================================================== --- gc_lang/fr/xpi/gce_worker.js +++ gc_lang/fr/xpi/gce_worker.js @@ -69,11 +69,11 @@ oLxg = new lxg.Lexicographe(oDict); if (sGCOptions !== "") { gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); } // we always retrieve options from the gce, for setOptions filters obsolete options - return gce.getOptions()._toString(); + return gce.getOptions().gl_toString(); } catch (e) { worker.log("# Error: " + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); } } @@ -89,30 +89,30 @@ let aSpellErr = oTokenizer.getSpellingErrors(sText, oDict); return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr }); } function getOptions () { - return gce.getOptions()._toString(); + return gce.getOptions().gl_toString(); } function getDefaultOptions () { - return gce.getDefaultOptions()._toString(); + return gce.getDefaultOptions().gl_toString(); } function setOptions (sGCOptions) { gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions))); - return gce.getOptions()._toString(); + return gce.getOptions().gl_toString(); } function setOption (sOptName, bValue) { gce.setOptions(new Map([ [sOptName, bValue] ])); - return gce.getOptions()._toString(); + return gce.getOptions().gl_toString(); } function resetOptions () { gce.resetOptions(); - return gce.getOptions()._toString(); + return gce.getOptions().gl_toString(); } function fullTests (sGCOptions="") { if (!gce || !oDict) { return "# Error: grammar checker or dictionary not loaded."