Overview
| Comment: | [tb] merge trunk: fix bugs |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | tb | multid |
| Files: | files | file ages | folders |
| SHA3-256: |
bce8dea5b06d250d6e2a0baafaaf113a |
| User & Date: | olr on 2018-02-18 10:13:44 |
| Other Links: | branch diff | manifest | tags |
Context
|
2018-02-18
| ||
| 16:28 | [lo] UI for dictionaries options check-in: edf22c7d52 user: olr tags: lo, multid | |
| 10:13 | [tb] merge trunk: fix bugs check-in: bce8dea5b0 user: olr tags: tb, multid | |
|
2018-02-17
| ||
| 12:59 | [graphspell][js][bug] wrong exported vars + test number instead of string check-in: 8c7797db95 user: olr tags: trunk, graphspell | |
| 11:31 | [graphspell][js][bug] spellchecker: dictionary not always a filename string check-in: ae469535bc user: olr tags: graphspell, multid | |
Changes
Modified gc_core/js/lang_core/gc_engine.js from [e7bf2c39e9] to [2ba338046d].
| ︙ | ︙ | |||
319 320 321 322 323 324 325 |
//// Initialization
load: function (sContext="JavaScript", sPath="") {
try {
if (typeof(require) !== 'undefined') {
var spellchecker = require("resource://grammalecte/graphspell/spellchecker.js");
| | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
//// Initialization
load: function (sContext="JavaScript", sPath="") {
try {
if (typeof(require) !== 'undefined') {
var spellchecker = require("resource://grammalecte/graphspell/spellchecker.js");
_oSpellChecker = new spellchecker.SpellChecker("${lang}", "", "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_personal_filename_js}");
} else {
_oSpellChecker = new SpellChecker("${lang}", sPath, "${dic_main_filename_js}", "${dic_extended_filename_js}", "${dic_personal_filename_js}");
}
_sAppContext = sContext;
_dOptions = gc_options.getOptions(sContext).gl_shallowCopy(); // duplication necessary, to be able to reset to default
}
catch (e) {
|
| ︙ | ︙ |
Modified gc_lang/fr/build.py from [248d1906b2] to [ea0f7f998e].
| ︙ | ︙ | |||
75 76 77 78 79 80 81 |
def createThunderbirdExtension (sLang, dVars, spLangPack):
"create extension for Thunderbird"
print("Building extension for Thunderbird")
sExtensionName = dVars['tb_identifier'] + "-v" + dVars['version'] + '.xpi'
spfZip = "_build/" + sExtensionName
hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
| | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
def createThunderbirdExtension (sLang, dVars, spLangPack):
"create extension for Thunderbird"
print("Building extension for Thunderbird")
sExtensionName = dVars['tb_identifier'] + "-v" + dVars['version'] + '.xpi'
spfZip = "_build/" + sExtensionName
hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
_copyGrammalecteJSPackageInZipFile(hZip, spLangPack)
for spf in ["LICENSE.txt", "LICENSE.fr.txt"]:
hZip.write(spf)
dVars = _createOptionsForThunderbird(dVars)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/tb", "", dVars, True)
spDict = "gc_lang/"+sLang+"/xpi/data/dictionaries"
for sp in os.listdir(spDict):
if os.path.isdir(spDict+"/"+sp):
|
| ︙ | ︙ | |||
106 107 108 109 110 111 112 |
dVars['sXULTabPanels'] += ' </tabpanel>\n'
# translation data
for sLang in dVars['dOptLabel'].keys():
dVars['gc_options_labels_'+sLang] = "\n".join( [ "<!ENTITY option.label." + sOpt + ' "' + dVars['dOptLabel'][sLang][sOpt][0] + '">' for sOpt in dVars['dOptLabel'][sLang] ] )
return dVars
| | > | > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
dVars['sXULTabPanels'] += ' </tabpanel>\n'
# translation data
for sLang in dVars['dOptLabel'].keys():
dVars['gc_options_labels_'+sLang] = "\n".join( [ "<!ENTITY option.label." + sOpt + ' "' + dVars['dOptLabel'][sLang][sOpt][0] + '">' for sOpt in dVars['dOptLabel'][sLang] ] )
return dVars
def _copyGrammalecteJSPackageInZipFile (hZip, spLangPack, sAddPath=""):
for sf in os.listdir("grammalecte-js"):
if not os.path.isdir("grammalecte-js/"+sf):
hZip.write("grammalecte-js/"+sf, sAddPath+"grammalecte-js/"+sf)
for sf in os.listdir("grammalecte-js/graphspell"):
if not os.path.isdir("grammalecte-js/graphspell/"+sf):
hZip.write("grammalecte-js/graphspell/"+sf, sAddPath+"grammalecte-js/graphspell/"+sf)
for sf in os.listdir("grammalecte-js/graphspell/_dictionaries"):
if not os.path.isdir("grammalecte-js/graphspell/_dictionaries/"+sf):
hZip.write("grammalecte-js/graphspell/_dictionaries/"+sf, sAddPath+"grammalecte-js/graphspell/_dictionaries/"+sf)
for sf in os.listdir(spLangPack):
if not os.path.isdir(spLangPack+"/"+sf):
hZip.write(spLangPack+"/"+sf, sAddPath+spLangPack+"/"+sf)
|
Modified gc_lang/fr/tb/worker/gce_worker.js from [245ae8ae9c] to [eba5411b89].
| ︙ | ︙ | |||
47 48 49 50 51 52 53 | let gce = null; // module: grammar checker engine let text = null; let tkz = null; // module: tokenizer let lxg = null; // module: lexicographer let helpers = null; let oTokenizer = null; | | | | | 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 |
let gce = null; // module: grammar checker engine
let text = null;
let tkz = null; // module: tokenizer
let lxg = null; // module: lexicographer
let helpers = null;
let oTokenizer = null;
let oSpellChecker = null;
let oLxg = null;
function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {
if (gce === null) {
try {
gce = require("resource://grammalecte/fr/gc_engine.js");
helpers = require("resource://grammalecte/graphspell/helpers.js");
text = require("resource://grammalecte/text.js");
tkz = require("resource://grammalecte/graphspell/tokenizer.js");
//lxg = require("resource://grammalecte/fr/lexicographe.js");
oTokenizer = new tkz.Tokenizer("fr");
//helpers.setLogOutput(worker.log);
gce.load(sContext);
oSpellChecker = gce.getSpellChecker();
if (sGCOptions !== "") {
gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
// we always retrieve options from the gce, for setOptions filters obsolete options
return gce.getOptions().gl_toString();
}
catch (e) {
console.log("# Error: " + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
}
}
function parse (sText, sCountry, bDebug, bContext) {
let aGrammErr = gce.parse(sText, sCountry, bDebug, bContext);
return JSON.stringify(aGrammErr);
}
function parseAndSpellcheck (sText, sCountry, bDebug, bContext) {
let aGrammErr = gce.parse(sText, sCountry, bDebug, bContext);
let aSpellErr = oTokenizer.getSpellingErrors(sText, oSpellChecker);
return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr });
}
function getOptions () {
return gce.getOptions().gl_toString();
}
|
| ︙ | ︙ | |||
109 110 111 112 113 114 115 |
function resetOptions () {
gce.resetOptions();
return gce.getOptions().gl_toString();
}
function fullTests (sGCOptions="") {
| | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
function resetOptions () {
gce.resetOptions();
return gce.getOptions().gl_toString();
}
function fullTests (sGCOptions="") {
if (!gce || !oSpellChecker) {
return "# Error: grammar checker or dictionary not loaded."
}
let dMemoOptions = gce.getOptions();
if (sGCOptions) {
gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
let tests = require("resource://grammalecte/tests.js");
|
| ︙ | ︙ |
Modified graphspell-js/ibdawg.js from [6c0fce95e9] to [08ad598b63].
| ︙ | ︙ | |||
118 119 120 121 122 123 124 |
this.byDic = lTemp;
//this.byDic = new Uint8Array(lTemp); // not quicker, even slower
/* end of bug workaround */
if (!this.sHeader.startsWith("/pyfsa/")) {
throw TypeError("# Error. Not a pyfsa binary dictionary. Header: " + this.sHeader);
}
| | | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
this.byDic = lTemp;
//this.byDic = new Uint8Array(lTemp); // not quicker, even slower
/* end of bug workaround */
if (!this.sHeader.startsWith("/pyfsa/")) {
throw TypeError("# Error. Not a pyfsa binary dictionary. Header: " + this.sHeader);
}
if (!(this.nCompressionMethod == 1 || this.nCompressionMethod == 2 || this.nCompressionMethod == 3)) {
throw RangeError("# Error. Unknown dictionary compression method: " + this.nCompressionMethod);
}
// <dChar> to get the value of an arc, <dCharVal> to get the char of an arc with its value
this.dChar = helpers.objectToMap(this.dChar);
this.dCharVal = this.dChar.gl_reverse();
if (this.cStemming == "S") {
|
| ︙ | ︙ |
Modified graphspell-js/spellchecker.js from [567dbb14f5] to [e878cd2181].
| ︙ | ︙ | |||
23 24 25 26 27 28 29 |
["fr", "fr.json"],
["en", "en.json"]
]);
class SpellChecker {
| | | | | 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 49 50 |
["fr", "fr.json"],
["en", "en.json"]
]);
class SpellChecker {
constructor (sLangCode, sPath="", mainDic="", extentedDic="", personalDic="") {
// returns true if the main dictionary is loaded
this.sLangCode = sLangCode;
if (!mainDic) {
mainDic = dDefaultDictionaries.gl_get(sLangCode, "");
}
this.oMainDic = this._loadDictionary(mainDic, sPath, true);
this.oExtendedDic = this._loadDictionary(extentedDic, sPath);
this.oPersonalDic = this._loadDictionary(personalDic, sPath);
}
_loadDictionary (dictionary, sPath, bNecessary=false) {
// returns an IBDAWG object
if (!dictionary) {
return null;
}
try {
if (typeof(require) !== 'undefined') {
return new ibdawg.IBDAWG(dictionary); // dictionary can be a filename or a JSON object
} else {
return new IBDAWG(dictionary, sPath); // dictionary can be a filename or a JSON object
|
| ︙ | ︙ | |||
155 156 157 158 159 160 161 |
if (this.oPersonalDic) {
yield* this.oPersonalDic.select(sPattern);
}
}
}
if (typeof(exports) !== 'undefined') {
| | | 155 156 157 158 159 160 161 162 163 |
if (this.oPersonalDic) {
yield* this.oPersonalDic.select(sPattern);
}
}
}
if (typeof(exports) !== 'undefined') {
exports.SpellChecker = SpellChecker;
}
|
Modified graphspell-js/str_transform.js from [047ef79ee5] to [4a82fc9e42].
| ︙ | ︙ | |||
209 210 211 212 213 214 215 |
sWord = sPfxCode.slice(1) + sWord.slice(sPfxCode.charCodeAt(0)-48);
return sSfxCode[0] == '0' ? sWord + sSfxCode.slice(1) : sWord.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
}
};
if (typeof(exports) !== 'undefined') {
| | | | 209 210 211 212 213 214 215 216 217 218 |
sWord = sPfxCode.slice(1) + sWord.slice(sPfxCode.charCodeAt(0)-48);
return sSfxCode[0] == '0' ? sWord + sSfxCode.slice(1) : sWord.slice(0, -(sSfxCode.charCodeAt(0)-48)) + sSfxCode.slice(1);
}
};
if (typeof(exports) !== 'undefined') {
exports.changeWordWithSuffixCode = str_transform.changeWordWithSuffixCode;
exports.changeWordWithAffixCode = str_transform.changeWordWithAffixCode;
}
|