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
|
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
|
-
+
-
+
-
+
|
#!python3
"""
Lexicon builder
"""
import argparse
import helpers
import os
import graphspell.dawg as fsa
def build (spfSrc, sLangCode, sLangName, sfDict, bJavaScript=False, sDicName="", sDescription="", sFilter="", cStemmingMethod="S", nCompressMethod=1):
"transform a text lexicon as a binary indexable dictionary"
oDAWG = fsa.DAWG(spfSrc, cStemmingMethod, sLangCode, sLangName, sDicName, sDescription, sFilter)
helpers.createFolder("graphspell/_dictionaries")
os.makedirs("graphspell/_dictionaries", exist_ok=True)
oDAWG.writeAsJSObject("graphspell/_dictionaries/" + sfDict + ".json")
if bJavaScript:
helpers.createFolder("graphspell-js/_dictionaries")
os.makedirs("graphspell-js/_dictionaries", exist_ok=True)
oDAWG.writeAsJSObject("graphspell-js/_dictionaries/" + sfDict + ".json")
def main ():
"parse args from CLI"
xParser = argparse.ArgumentParser()
xParser.add_argument("src_lexicon", type=str, help="path and file name of the source lexicon")
|