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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
// Grammalecte - Conjugueur
// License: GPL 3
"use strict";
${map}
let helpers = null; // module not loaded in Firefox content script
let _oData = {};
let _lVtyp = null;
let _lTags = null;
let _dPatternConj = {};
let _dVerb = {};
if (typeof(exports) !== 'undefined') {
// used within Grammalecte library
helpers = require("resource://grammalecte/helpers.js");
_oData = JSON.parse(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
_lVtyp = _oData.lVtyp;
_lTags = _oData.lTags;
_dPatternConj = _oData.dPatternConj;
_dVerb = _oData.dVerb;
} else {
// 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 (sData) {
_oData = JSON.parse(sData);
_lVtyp = _oData.lVtyp;
_lTags = _oData.lTags;
_dPatternConj = _oData.dPatternConj;
_dVerb = _oData.dVerb;
});
}
const _zStartVoy = new RegExp("^[aeéiouœê]");
const _zNeedTeuph = new RegExp("[tdc]$");
const _dProSuj = new Map ([ [":1s", "je"], [":1ś", "je"], [":2s", "tu"], [":3s", "il"], [":1p", "nous"], [":2p", "vous"], [":3p", "ils"] ]);
const _dProObj = new Map ([ [":1s", "me "], [":1ś", "me "], [":2s", "te "], [":3s", "se "], [":1p", "nous "], [":2p", "vous "], [":3p", "se "] ]);
const _dProObjEl = new Map ([ [":1s", "m’"], [":1ś", "m’"], [":2s", "t’"], [":3s", "s’"], [":1p", "nous "], [":2p", "vous "], [":3p", "s’"] ]);
const _dImpePro = new Map ([ [":2s", "-toi"], [":1p", "-nous"], [":2p", "-vous"] ]);
const _dImpeProNeg = new Map ([ [":2s", "ne te "], [":1p", "ne nous "], [":2p", "ne vous "] ]);
const _dImpeProEn = new Map ([ [":2s", "-t’en"], [":1p", "-nous-en"], [":2p", "-vous-en"] ]);
const _dImpeProNegEn = new Map ([ [":2s", "ne t’en "], [":1p", "ne nous en "], [":2p", "ne vous en "] ]);
const _dGroup = new Map ([ ["0", "auxiliaire"], ["1", "1ᵉʳ groupe"], ["2", "2ᵉ groupe"], ["3", "3ᵉ groupe"] ]);
const _dTenseIdx = new Map ([ [":PQ", 0], [":Ip", 1], [":Iq", 2], [":Is", 3], [":If", 4], [":K", 5], [":Sp", 6], [":Sq", 7], [":E", 8] ]);
function isVerb (sVerb) {
return _dVerb.hasOwnProperty(sVerb);
}
function getConj (sVerb, sTense, sWho) {
// returns conjugation (can be an empty string)
if (!_dVerb.hasOwnProperty(sVerb)) {
return null;
}
if (!_dPatternConj[sTense][_lTags[_dVerb[sVerb][1]][_dTenseIdx.get(sTense)]].hasOwnProperty(sWho)) {
return "";
}
return _modifyStringWithSuffixCode(sVerb, _dPatternConj[sTense][_lTags[_dVerb[sVerb][1]][_dTenseIdx.get(sTense)]][sWho]);
}
function hasConj (sVerb, sTense, sWho) {
// returns false if no conjugation (also if empty) else true
if (!_dVerb.hasOwnProperty(sVerb)) {
return false;
}
if (_dPatternConj[sTense][_lTags[_dVerb[sVerb][1]][_dTenseIdx.get(sTense)]].hasOwnProperty(sWho)
&& _dPatternConj[sTense][_lTags[_dVerb[sVerb][1]][_dTenseIdx.get(sTense)]][sWho]) {
return true;
}
return false;
}
function getVtyp (sVerb) {
// returns raw informations about sVerb
if (!_dVerb.hasOwnProperty(sVerb)) {
return null;
}
return _lVtyp[_dVerb[sVerb][0]];
}
function getSimil (sWord, sMorph, sFilter=null) {
if (!sMorph.includes(":V")) {
return new Set();
}
let sInfi = sMorph.slice(1, sMorph.indexOf(" "));
let tTags = _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(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":2p"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":1s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Iq", ":3p"));
} else if (sMorph.includes(":V2")) {
aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
} else if (sMorph.includes(":V3")) {
aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":1s"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":Is", ":3s"));
} else if (isMorph.includes(":V0a")) {
aSugg.add("eus");
aSugg.add("eut");
} else {
aSugg.add("étais");
aSugg.add("était");
}
aSugg.delete("");
} else {
// we suggest past participles
aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q1"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q2"));
aSugg.add(_getConjWithTags(sInfi, tTags, ":PQ", ":Q3"));
aSugg.add(_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;
}
function _getTags (sVerb) {
// returns tuple of tags (usable with functions _getConjWithTags and _hasConjWithTags)
if (!_dVerb.hasOwnProperty(sVerb)) {
return null;
}
return _lTags[_dVerb[sVerb][1]];
}
function _getConjWithTags (sVerb, tTags, sTense, sWho) {
// returns conjugation (can be an empty string)
if (!_dPatternConj[sTense][tTags[_dTenseIdx.get(sTense)]].hasOwnProperty(sWho)) {
return "";
}
return _modifyStringWithSuffixCode(sVerb, _dPatternConj[sTense][tTags[_dTenseIdx.get(sTense)]][sWho]);
}
function _hasConjWithTags (tTags, sTense, sWho) {
// returns false if no conjugation (also if empty) else true
if (_dPatternConj[sTense][tTags[_dTenseIdx.get(sTense)]].hasOwnProperty(sWho)
&& _dPatternConj[sTense][tTags[_dTenseIdx.get(sTense)]][sWho]) {
return true;
}
return false;
}
function _modifyStringWithSuffixCode (sWord, sSfx) {
// returns sWord modified by sSfx
if (sSfx === "") {
return "";
}
if (sSfx === "0") {
return sWord;
}
try {
if (sSfx[0] !== '0') {
return sWord.slice(0, -(sSfx.charCodeAt(0)-48)) + sSfx.slice(1); // 48 is the ASCII code for "0"
} else {
return sWord + sSfx.slice(1);
}
}
catch (e) {
console.log(e);
return "## erreur, code : " + sSfx + " ##";
}
}
class Verb {
constructor (sVerb) {
if (typeof sVerb !== "string" || sVerb === "") {
throw new TypeError ("The value should be a non-empty string");
}
this.sVerb = sVerb;
this.sVerbAux = "";
this._sRawInfo = getVtyp(this.sVerb);
this.sInfo = this._readableInfo(this._sRawInfo);
this._tTags = _getTags(sVerb);
this._tTagsAux = _getTags(this.sVerbAux);
this.bProWithEn = (this._sRawInfo[5] === "e");
this.dConj = new Map ([
[":Y", new Map ([
["label", "Infinitif"],
[":Y", sVerb]
])],
[":PQ", new Map ([
["label", "Participes passés et présent"],
[":Q1", _getConjWithTags(sVerb, this._tTags, ":PQ", ":Q1")],
[":Q2", _getConjWithTags(sVerb, this._tTags, ":PQ", ":Q2")],
[":Q3", _getConjWithTags(sVerb, this._tTags, ":PQ", ":Q3")],
[":Q4", _getConjWithTags(sVerb, this._tTags, ":PQ", ":Q4")],
[":P", _getConjWithTags(sVerb, this._tTags, ":PQ", ":P")]
])],
[":Ip", new Map ([
["label", "Présent"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":Ip", ":1s")],
[":1ś", _getConjWithTags(sVerb, this._tTags, ":Ip", ":1ś")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":Ip", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":Ip", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":Ip", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":Ip", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":Ip", ":3p")]
])],
[":Iq", new Map ([
["label", "Imparfait"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":Iq", ":1s")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":Iq", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":Iq", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":Iq", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":Iq", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":Iq", ":3p")]
])],
[":Is", new Map ([
["label", "Passé simple"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":Is", ":1s")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":Is", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":Is", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":Is", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":Is", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":Is", ":3p")]
])],
[":If", new Map ([
["label", "Futur"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":If", ":1s")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":If", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":If", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":If", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":If", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":If", ":3p")]
])],
[":Sp", new Map ([
["label", "Présent subjonctif"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":Sp", ":1s")],
[":1ś", _getConjWithTags(sVerb, this._tTags, ":Sp", ":1ś")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":Sp", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":Sp", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":Sp", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":Sp", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":Sp", ":3p")]
])],
[":Sq", new Map ([
["label", "Imparfait subjonctif"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":Sq", ":1s")],
[":1ś", _getConjWithTags(sVerb, this._tTags, ":Sq", ":1ś")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":Sq", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":Sq", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":Sq", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":Sq", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":Sq", ":3p")]
])],
[":K", new Map ([
["label", "Conditionnel"],
[":1s", _getConjWithTags(sVerb, this._tTags, ":K", ":1s")],
[":2s", _getConjWithTags(sVerb, this._tTags, ":K", ":2s")],
[":3s", _getConjWithTags(sVerb, this._tTags, ":K", ":3s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":K", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":K", ":2p")],
[":3p", _getConjWithTags(sVerb, this._tTags, ":K", ":3p")]
])],
[":E", new Map ([
["label", "Impératif"],
[":2s", _getConjWithTags(sVerb, this._tTags, ":E", ":2s")],
[":1p", _getConjWithTags(sVerb, this._tTags, ":E", ":1p")],
[":2p", _getConjWithTags(sVerb, this._tTags, ":E", ":2p")]
])]
]);
};
_readableInfo () {
// returns readable infos
this.sVerbAux = (this._sRawInfo.slice(7,8) == "e") ? "être" : "avoir";
let sGroup = _dGroup.get(this._sRawInfo[0]);
let sInfo = "";
if (this._sRawInfo.slice(3,4) == "t") {
sInfo = "transitif";
} else if (this._sRawInfo.slice(4,5) == "n") {
sInfo = "transitif indirect";
} else if (this._sRawInfo.slice(2,3) == "i") {
sInfo = "intransitif";
|
<
|
<
|
|
|
|
|
<
<
<
<
<
<
<
<
|
<
<
<
|
|
|
|
|
<
|
>
>
|
>
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
// Grammalecte - Conjugueur
// License: GPL 3
"use strict";
${map}
var conj = {
_lVtyp: [],
_lTags: [],
_dPatternConj: {},
_dVerb: {},
init: function (sJSONData) {
try {
let _oData = JSON.parse(sJSONData);
this._lVtyp = _oData.lVtyp;
this._lTags = _oData.lTags;
this._dPatternConj = _oData.dPatternConj;
this._dVerb = _oData.dVerb;
}
catch (e) {
console.error(e);
}
},
_zStartVoy: new RegExp("^[aeéiouœê]"),
_zNeedTeuph: new RegExp("[tdc]$"),
_dProSuj: new Map ([ [":1s", "je"], [":1ś", "je"], [":2s", "tu"], [":3s", "il"], [":1p", "nous"], [":2p", "vous"], [":3p", "ils"] ]),
_dProObj: new Map ([ [":1s", "me "], [":1ś", "me "], [":2s", "te "], [":3s", "se "], [":1p", "nous "], [":2p", "vous "], [":3p", "se "] ]),
_dProObjEl: new Map ([ [":1s", "m’"], [":1ś", "m’"], [":2s", "t’"], [":3s", "s’"], [":1p", "nous "], [":2p", "vous "], [":3p", "s’"] ]),
_dImpePro: new Map ([ [":2s", "-toi"], [":1p", "-nous"], [":2p", "-vous"] ]),
_dImpeProNeg: new Map ([ [":2s", "ne te "], [":1p", "ne nous "], [":2p", "ne vous "] ]),
_dImpeProEn: new Map ([ [":2s", "-t’en"], [":1p", "-nous-en"], [":2p", "-vous-en"] ]),
_dImpeProNegEn: new Map ([ [":2s", "ne t’en "], [":1p", "ne nous en "], [":2p", "ne vous en "] ]),
_dGroup: new Map ([ ["0", "auxiliaire"], ["1", "1ᵉʳ groupe"], ["2", "2ᵉ groupe"], ["3", "3ᵉ groupe"] ]),
_dTenseIdx: new Map ([ [":PQ", 0], [":Ip", 1], [":Iq", 2], [":Is", 3], [":If", 4], [":K", 5], [":Sp", 6], [":Sq", 7], [":E", 8] ]),
isVerb: function (sVerb) {
return this._dVerb.hasOwnProperty(sVerb);
},
getConj: function (sVerb, sTense, sWho) {
// returns conjugation (can be an empty string)
if (!this._dVerb.hasOwnProperty(sVerb)) {
return null;
}
if (!this._dPatternConj[sTense][this._lTags[this._dVerb[sVerb][1]][this._dTenseIdx.get(sTense)]].hasOwnProperty(sWho)) {
return "";
}
return this._modifyStringWithSuffixCode(sVerb, this._dPatternConj[sTense][this._lTags[this._dVerb[sVerb][1]][this._dTenseIdx.get(sTense)]][sWho]);
},
hasConj: function (sVerb, sTense, sWho) {
// returns false if no conjugation (also if empty) else true
if (!this._dVerb.hasOwnProperty(sVerb)) {
return false;
}
if (this._dPatternConj[sTense][this._lTags[this._dVerb[sVerb][1]][this._dTenseIdx.get(sTense)]].hasOwnProperty(sWho)
&& this._dPatternConj[sTense][this._lTags[this._dVerb[sVerb][1]][this._dTenseIdx.get(sTense)]][sWho]) {
return true;
}
return false;
},
getVtyp: function (sVerb) {
// 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"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Iq", ":3p"));
} else if (sMorph.includes(":V2")) {
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
} else if (sMorph.includes(":V3")) {
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":1s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Ip", ":3s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Is", ":1s"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":Is", ":3s"));
} else if (isMorph.includes(":V0a")) {
aSugg.add("eus");
aSugg.add("eut");
} else {
aSugg.add("étais");
aSugg.add("était");
}
aSugg.delete("");
} else {
// we suggest past participles
aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q1"));
aSugg.add(this._getConjWithTags(sInfi, tTags, ":PQ", ":Q2"));
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)) {
return null;
}
return this._lTags[this._dVerb[sVerb][1]];
},
_getConjWithTags: function (sVerb, tTags, sTense, sWho) {
// returns conjugation (can be an empty string)
if (!this._dPatternConj[sTense][tTags[this._dTenseIdx.get(sTense)]].hasOwnProperty(sWho)) {
return "";
}
return this._modifyStringWithSuffixCode(sVerb, this._dPatternConj[sTense][tTags[this._dTenseIdx.get(sTense)]][sWho]);
},
_hasConjWithTags: function (tTags, sTense, sWho) {
// returns false if no conjugation (also if empty) else true
if (this._dPatternConj[sTense][tTags[this._dTenseIdx.get(sTense)]].hasOwnProperty(sWho)
&& this._dPatternConj[sTense][tTags[this._dTenseIdx.get(sTense)]][sWho]) {
return true;
}
return false;
},
_modifyStringWithSuffixCode: function (sWord, sSfx) {
// returns sWord modified by sSfx
if (sSfx === "") {
return "";
}
if (sSfx === "0") {
return sWord;
}
try {
if (sSfx[0] !== '0') {
return sWord.slice(0, -(sSfx.charCodeAt(0)-48)) + sSfx.slice(1); // 48 is the ASCII code for "0"
} else {
return sWord + sSfx.slice(1);
}
}
catch (e) {
console.log(e);
return "## erreur, code : " + sSfx + " ##";
}
}
}
class Verb {
constructor (sVerb) {
if (typeof sVerb !== "string" || sVerb === "") {
throw new TypeError ("The value should be a non-empty string");
}
this.sVerb = sVerb;
this.sVerbAux = "";
this._sRawInfo = conj.getVtyp(this.sVerb);
this.sInfo = this._readableInfo(this._sRawInfo);
this._tTags = conj._getTags(sVerb);
this._tTagsAux = conj._getTags(this.sVerbAux);
this.bProWithEn = (this._sRawInfo[5] === "e");
this.dConj = new Map ([
[":Y", new Map ([
["label", "Infinitif"],
[":Y", sVerb]
])],
[":PQ", new Map ([
["label", "Participes passés et présent"],
[":Q1", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q1")],
[":Q2", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q2")],
[":Q3", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q3")],
[":Q4", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":Q4")],
[":P", conj._getConjWithTags(sVerb, this._tTags, ":PQ", ":P")]
])],
[":Ip", new Map ([
["label", "Présent"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":1s")],
[":1ś", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":1ś")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":Ip", ":3p")]
])],
[":Iq", new Map ([
["label", "Imparfait"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":Iq", ":1s")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":Iq", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":Iq", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":Iq", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":Iq", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":Iq", ":3p")]
])],
[":Is", new Map ([
["label", "Passé simple"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":Is", ":1s")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":Is", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":Is", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":Is", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":Is", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":Is", ":3p")]
])],
[":If", new Map ([
["label", "Futur"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":If", ":1s")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":If", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":If", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":If", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":If", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":If", ":3p")]
])],
[":Sp", new Map ([
["label", "Présent subjonctif"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":1s")],
[":1ś", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":1ś")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":Sp", ":3p")]
])],
[":Sq", new Map ([
["label", "Imparfait subjonctif"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":1s")],
[":1ś", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":1ś")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":Sq", ":3p")]
])],
[":K", new Map ([
["label", "Conditionnel"],
[":1s", conj._getConjWithTags(sVerb, this._tTags, ":K", ":1s")],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":K", ":2s")],
[":3s", conj._getConjWithTags(sVerb, this._tTags, ":K", ":3s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":K", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":K", ":2p")],
[":3p", conj._getConjWithTags(sVerb, this._tTags, ":K", ":3p")]
])],
[":E", new Map ([
["label", "Impératif"],
[":2s", conj._getConjWithTags(sVerb, this._tTags, ":E", ":2s")],
[":1p", conj._getConjWithTags(sVerb, this._tTags, ":E", ":1p")],
[":2p", conj._getConjWithTags(sVerb, this._tTags, ":E", ":2p")]
])]
]);
};
_readableInfo () {
// returns readable infos
this.sVerbAux = (this._sRawInfo.slice(7,8) == "e") ? "être" : "avoir";
let sGroup = conj._dGroup.get(this._sRawInfo[0]);
let sInfo = "";
if (this._sRawInfo.slice(3,4) == "t") {
sInfo = "transitif";
} else if (this._sRawInfo.slice(4,5) == "n") {
sInfo = "transitif indirect";
} else if (this._sRawInfo.slice(2,3) == "i") {
sInfo = "intransitif";
|