Grammalecte  Diff

Differences From Artifact [538b8f5fd2]:

To Artifact [a24db6ede9]:


1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
#!python3

# FRENCH DATA BUILDER
#
# by Olivier R.
# License: MPL 2

import json
import os
import itertools
import traceback
import platform
import importlib


import graphspell.ibdawg as ibdawg
from graphspell.echo import echo
from graphspell.str_transform import defineSuffixCode
import graphspell.tokenizer as tkz















>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!python3

# FRENCH DATA BUILDER
#
# by Olivier R.
# License: MPL 2

import json
import os
import itertools
import traceback
import platform
import importlib
import shutil

import graphspell.ibdawg as ibdawg
from graphspell.echo import echo
from graphspell.str_transform import defineSuffixCode
import graphspell.tokenizer as tkz


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
    with cd(sp+"/dictionnaire"):
        if platform.system() == "Windows":
            os.system("python genfrdic.py -s -gl -v "+sVersion)
        else:
            os.system("python3 ./genfrdic.py -s -gl -v "+sVersion)


def makeThesaurusFiles (sp):
    dThesaurus = {}
    sContent = open(sp+'/data/thes_fr.json', "r", encoding="utf-8").read()
    dThesaurus = json.loads(sContent)
    ## write file for Python
    sCode = "# generated data (do not edit)\n\n" + \
            "dThesaurus = " + str(dThesaurus) + "\n"
    open(sp+"/modules/thesaurus_data.py", "w", encoding="utf-8", newline="\n").write(sCode)
    if bJS:
        ## write file for JavaScript
        file_util.copy_file(sp+'/data/thes_fr.json', sp+"/modules-js/thesaurus_data.json")


def makeConj (sp, bJS=False):
    print("> Conjugaisons ", end="")
    print("(Python et JavaScript)"  if bJS  else "(Python seulement)")
    dVerb = {}
    lVinfo = []; dVinfo = {}; nVinfo = 0







|









|







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
    with cd(sp+"/dictionnaire"):
        if platform.system() == "Windows":
            os.system("python genfrdic.py -s -gl -v "+sVersion)
        else:
            os.system("python3 ./genfrdic.py -s -gl -v "+sVersion)


def makeThesaurusFiles (sp, bJS=False):
    dThesaurus = {}
    sContent = open(sp+'/data/thes_fr.json', "r", encoding="utf-8").read()
    dThesaurus = json.loads(sContent)
    ## write file for Python
    sCode = "# generated data (do not edit)\n\n" + \
            "dThesaurus = " + str(dThesaurus) + "\n"
    open(sp+"/modules/thesaurus_data.py", "w", encoding="utf-8", newline="\n").write(sCode)
    if bJS:
        ## write file for JavaScript
        shutil.copy2(sp+'/data/thes_fr.json', sp+"/modules-js/thesaurus_data.json")


def makeConj (sp, bJS=False):
    print("> Conjugaisons ", end="")
    print("(Python et JavaScript)"  if bJS  else "(Python seulement)")
    dVerb = {}
    lVinfo = []; dVinfo = {}; nVinfo = 0
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370

                '    "dWord": ' + json.dumps(dWord, ensure_ascii=False) + ",\n" + \
                '    "lSet": ' + json.dumps(lSet, ensure_ascii=False) + ",\n" + \
                '    "dMorph": ' + json.dumps(dMorph, ensure_ascii=False) + "\n}"
        open(sp+"/modules-js/phonet_data.json", "w", encoding="utf-8", newline="\n").write(sCode)


def before (spLaunch, dVars, bJS=False):
    print("========== Build Hunspell dictionaries ==========")
    makeDictionaries(spLaunch, dVars['oxt_version'])


def after (spLaunch, dVars, bJS=False):
    print("========== Build French data ==========")
    makeMfsp(spLaunch, bJS)
    makeConj(spLaunch, bJS)
    makePhonetTable(spLaunch, bJS)








|

|






>
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
                '    "dWord": ' + json.dumps(dWord, ensure_ascii=False) + ",\n" + \
                '    "lSet": ' + json.dumps(lSet, ensure_ascii=False) + ",\n" + \
                '    "dMorph": ' + json.dumps(dMorph, ensure_ascii=False) + "\n}"
        open(sp+"/modules-js/phonet_data.json", "w", encoding="utf-8", newline="\n").write(sCode)


def before (spLaunch, dVars, bJS=False):
    print("========== Build Hunspell dictionaries / Thesaurus ==========")
    makeDictionaries(spLaunch, dVars['oxt_version'])
    makeThesaurusFiles(spLaunch, bJS)

def after (spLaunch, dVars, bJS=False):
    print("========== Build French data ==========")
    makeMfsp(spLaunch, bJS)
    makeConj(spLaunch, bJS)
    makePhonetTable(spLaunch, bJS)