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
|
#!python3
# Lexicon builder
import argparse
from distutils import dir_util
import grammalecte.dawg as fsa
from grammalecte.ibdawg import IBDAWG
def build (spfSrc, sLangName, sDicName, bJSON=False, cStemmingMethod="S", nCompressMethod=1):
"transform a text lexicon as a binary indexable dictionary"
oDAWG = fsa.DAWG(spfSrc, sLangName, cStemmingMethod)
dir_util.mkpath("grammalecte/_dictionaries")
oDAWG.writeInfo("grammalecte/_dictionaries/" + sDicName + ".info.txt")
oDAWG.createBinary("grammalecte/_dictionaries/" + sDicName + ".bdic", int(nCompressMethod))
if bJSON:
dir_util.mkpath("grammalecte-js/_dictionaries")
oDic = IBDAWG(sDicName + ".bdic")
oDic.writeAsJSObject("grammalecte-js/_dictionaries/" + sDicName + ".json", bBinaryDictAsHexString=True)
def main ():
xParser = argparse.ArgumentParser()
xParser.add_argument("src_lexicon", type=str, help="path and file name of the source lexicon")
xParser.add_argument("lang_name", type=str, help="language name")
xParser.add_argument("dic_name", type=str, help="dictionary file name (without extension)")
|
|
|
|
|
|
|
|
|
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
|
#!python3
# Lexicon builder
import argparse
from distutils import dir_util
import graphspell.dawg as fsa
from graphspell.ibdawg import IBDAWG
def build (spfSrc, sLangName, sDicName, bJSON=False, cStemmingMethod="S", nCompressMethod=1):
"transform a text lexicon as a binary indexable dictionary"
oDAWG = fsa.DAWG(spfSrc, sLangName, cStemmingMethod)
dir_util.mkpath("graphspell/_dictionaries")
oDAWG.writeInfo("graphspell/_dictionaries/" + sDicName + ".info.txt")
oDAWG.createBinary("graphspell/_dictionaries/" + sDicName + ".bdic", int(nCompressMethod))
if bJSON:
dir_util.mkpath("graphspell-js/_dictionaries")
oDic = IBDAWG(sDicName + ".bdic")
oDic.writeAsJSObject("graphspell-js/_dictionaries/" + sDicName + ".json", bBinaryDictAsHexString=True)
def main ():
xParser = argparse.ArgumentParser()
xParser.add_argument("src_lexicon", type=str, help="path and file name of the source lexicon")
xParser.add_argument("lang_name", type=str, help="language name")
xParser.add_argument("dic_name", type=str, help="dictionary file name (without extension)")
|