79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// returns raw informations about sVerb
if (!this._dVerb.hasOwnProperty(sVerb)) {
return null;
}
return this._lVtyp[this._dVerb[sVerb][0]];
},
getSimil: function (sWord, sMorph, sFilter=null) {
if (!sMorph.includes(":V")) {
return new Set();
}
let sInfi = sMorph.slice(1, sMorph.indexOf(" "));
let tTags = this._getTags(sInfi);
let aSugg = new Set();
if (sMorph.includes(":Q") || sMorph.includes(":Y")) {
// we suggest conjugated forms
if (sMorph.includes(":V1")) {
aSugg.add(sInfi);
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":2p"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":1s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3s"));
|
|
|
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// returns raw informations about sVerb
if (!this._dVerb.hasOwnProperty(sVerb)) {
return null;
}
return this._lVtyp[this._dVerb[sVerb][0]];
},
getSimil: function (sWord, sMorph, bSubst=false) {
if (!sMorph.includes(":V")) {
return new Set();
}
let sInfi = sMorph.slice(1, sMorph.indexOf(" "));
let tTags = this._getTags(sInfi);
let aSugg = new Set();
if (!bSubst) {
// we suggest conjugated forms
if (sMorph.includes(":V1")) {
aSugg.add(sInfi);
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":2p"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":1s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3s"));
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q3"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q4"));
aSugg.delete("");
// if there is only one past participle (epi inv), unreliable.
if (aSugg.size === 1) {
aSugg.clear();
}
if (sMorph.includes(":V1")) {
aSugg.add(sInfi);
}
}
return aSugg;
},
_getTags: function (sVerb) {
// returns tuple of tags (usable with functions _getConjWithTags and _hasConjWithTags)
if (!this._dVerb.hasOwnProperty(sVerb)) {
|
<
<
<
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q3"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q4"));
aSugg.delete("");
// if there is only one past participle (epi inv), unreliable.
if (aSugg.size === 1) {
aSugg.clear();
}
}
return aSugg;
},
_getTags: function (sVerb) {
// returns tuple of tags (usable with functions _getConjWithTags and _hasConjWithTags)
if (!this._dVerb.hasOwnProperty(sVerb)) {
|
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
return (this.dConj.get(":PQ").get(":Q4")) ? this.dConj.get(":PQ").get(":Q4") : this.dConj.get(":PQ").get(":Q1");
}
}
// Initialization
if (!conj.bInit && typeof(browser) !== 'undefined') {
// WebExtension (but not in Worker)
conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(require) !== 'undefined') {
// Add-on SDK and Thunderbird
conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
} else if ( !conj.bInit && typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) !== "undefined") {
// used within Firefox content script (conjugation panel).
// can’t load JSON from here, so we do it in ui.js and send it here.
self.port.on("provideConjData", function (sJSONData) {
conj.init(sJSONData);
});
} else if (conj.bInit){
console.log("Module conj déjà initialisé");
|
|
>
>
>
|
|
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
return (this.dConj.get(":PQ").get(":Q4")) ? this.dConj.get(":PQ").get(":Q4") : this.dConj.get(":PQ").get(":Q1");
}
}
// Initialization
if (!conj.bInit && typeof(browser) !== 'undefined') {
// WebExtension Standard (but not in Worker)
conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(chrome) !== 'undefined') {
// WebExtension Chrome (but not in Worker)
conj.init(helpers.loadFile(chrome.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(require) !== 'undefined') {
// Add-on SDK and Thunderbird
conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
} else if (!conj.bInit && typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) !== "undefined") {
// used within Firefox content script (conjugation panel).
// can’t load JSON from here, so we do it in ui.js and send it here.
self.port.on("provideConjData", function (sJSONData) {
conj.init(sJSONData);
});
} else if (conj.bInit){
console.log("Module conj déjà initialisé");
|