Grammalecte  Diff

Differences From Artifact [c256239800]:

To Artifact [858a6f42b2]:


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
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







-
+

-
-
+
+



-
+





-
+


-
+

-
+

-
+

-
+

-
+

-
+




-
+
+


-
+


-
-
+
+

-
-
+
+



-
+

-
+





-
-
+
+
-
-

-
-
+
+










-
+










-
+







            hDst.write('    "dVerbNames": ' + json.dumps(dVerbNames, ensure_ascii=False) + "\n")
            hDst.write("}\n")


def makeMfsp (sp, bJS=False):
    print("> Pluriel/singulier/masculin/féminin ", end="")
    print("(Python et JavaScript)"  if bJS  else "(Python seulement)")
    aPlurS = set()
    aPlurS = set()      # pluriels en -s
    dTag = {}
    lTagMasForm = []
    lTagMiscPlur = []
    lTagFemForm = []
    lTagMiscPlur = []   # pluriels spéciaux
    dMiscPlur = {}
    dMasForm = {}
    lTag = []
    lTagMasPl = []
    lTagFemPl = []
    for n, sLine in enumerate(readFile(sp+"/data/dictDecl.txt")):
        nTab = sLine.count("\t")
        if nTab == 1:
            # new entry
            lTag.clear()
            lTagMasPl.clear()
            lTagFemPl.clear()
            sLemma, sFlags = sLine.split("\t")
            if sFlags.startswith("S"):
                cType = "s"
                cType = "sg"
            elif sFlags.startswith("X"):
                cType = "p"
                cType = "pl"
            elif sFlags.startswith("A"):
                cType = "p"
                cType = "pl"
            elif sFlags.startswith("I"):
                cType = "p"
                cType = "pl"
            elif sFlags.startswith("F"):
                cType = "m"
                cType = "mf"
            elif sFlags.startswith("W"):
                cType = "m"
                cType = "mf"
            else:
                cType = "?"
                print(" > inconnu : " + sFlags)
        elif nTab == 2:
            if cType == "s":
            if cType == "sg":
                # nothing to do
                continue
            _, sFlexTags, sFlex = sLine.split("\t")
            if cType == "p":
            if cType == "pl":
                if sFlexTags.endswith("pl"):
                    lTag.append(defineSuffixCode(sLemma, sFlex))
            elif cType == "m":
                if sFlexTags.endswith("mas sg") or sFlexTags.endswith("mas inv"):
            elif cType == "mf":
                if sFlexTags.endswith("fem sg"):
                    lTag.append(defineSuffixCode(sLemma, sFlex))
                if sFlexTags.endswith("mas pl"):
                    lTagMasPl.append(defineSuffixCode(sLemma, sFlex))
                if sFlexTags.endswith("fem pl"):
                    lTagFemPl.append(defineSuffixCode(sLemma, sFlex))
            else:
                print("erreur: " + cType)
        elif sLine == "$":
            if cType == "s":
            if cType == "sg":
                aPlurS.add(sLemma)
            elif cType == "p":
            elif cType == "pl":
                sTag = "|".join(lTag)
                if sTag not in dTag:
                    dTag[sTag] = len(lTagMiscPlur)
                    lTagMiscPlur.append(sTag)
                dMiscPlur[sLemma] = dTag[sTag]
            elif cType == "m":
                sTag = "|".join(lTag)
            elif cType == "mf":
                sTag = "|".join(lTag) + "/" + "|".join(lTagFemPl)
                if lTagMasPl:
                    sTag += "/" + "|".join(lTagMasPl)
                if sTag not in dTag:
                    dTag[sTag] = len(lTagMasForm)
                    lTagMasForm.append(sTag)
                    dTag[sTag] = len(lTagFemForm)
                    lTagFemForm.append(sTag)
                dMasForm[sLemma] = dTag[sTag]
            else:
                print("unknown tag: " + ctype)
        else:
            print("# Error - unknown line #", n)

    ## write file for Python
    sCode = "# generated data (do not edit)\n\n" + \
            "# list of affix codes\n" + \
            "lTagMiscPlur = " + str(lTagMiscPlur) + "\n" + \
            "lTagMasForm = " + str(lTagMasForm) + "\n\n" + \
            "lTagFemForm = " + str(lTagFemForm) + "\n\n" + \
            "# dictionary of words with uncommon plurals (-x, -ux, english, latin and italian plurals) and tags to generate them\n" + \
            "dMiscPlur = " + str(dMiscPlur) + "\n\n" + \
            "# dictionary of feminine forms and tags to generate masculine forms (singular and plural)\n" + \
            "dMasForm = " + str(dMasForm) + "\n"
    open(sp+"/modules/mfsp_data.py", "w", encoding="utf-8", newline="\n").write(sCode)

    if bJS:
        ## write file for JavaScript
        sCode = '{\n' + \
                '    "lTagMiscPlur": ' +  json.dumps(lTagMiscPlur, ensure_ascii=False) + ",\n" + \
                '    "lTagMasForm": ' +  json.dumps(lTagMasForm, ensure_ascii=False) + ",\n" + \
                '    "lTagFemForm": ' +  json.dumps(lTagFemForm, ensure_ascii=False) + ",\n" + \
                '    "dMiscPlur": ' +  json.dumps(dMiscPlur, ensure_ascii=False) + ",\n" + \
                '    "dMasForm": ' +  json.dumps(dMasForm, ensure_ascii=False) + "\n}"
        open(sp+"/modules-js/mfsp_data.json", "w", encoding="utf-8", newline="\n").write(sCode)


def makePhonetTable (sp, bJS=False):
    print("> Correspondances phonétiques ", end="")