예제 #1
0
# Add pylmflib/ folder to path
sys.path.append(user_path + '..')

# Create result folder
if not os.path.exists(user_path + "na/result"):
    os.mkdir(user_path + "na/result")

# Import LMF library
import pylmflib

# Import user customized configuration
# Les variables de type pylmflib.config.xml.TRUC correspondent à un attribut TRUC sous <Config><Language><lang> dans le fichier config.xml local !
from setting import tex_eng, tex_fra, tex_cmn, items, classify_lexicon

# Read user configuration
lexical_resource = pylmflib.read_config(user_path + "na/config.xml")

# Read MDF file, generate UID and set lexicon identifier
os.system("python2 " + user_path + "../pylmflib/utils/eol/eol.py -i " +
          user_path + "na/Dictionary.txt -o " + user_path +
          "na/result/dictionary-eol.txt")
os.system("python2 " + user_path + "../pylmflib/utils/uid/uid.py -i " +
          user_path + "na/result/dictionary-eol.txt -o " + user_path +
          "na/result/dictionary-uid.txt")
lexical_resource = pylmflib.read_mdf(id="na")

# Classify lexicon
(xml_order,
 xml_type) = pylmflib.read_sort_order(user_path + "na/sort_order.xml")
classify_lexicon(lexical_resource.get_lexicon("na"), xml_order, xml_type)
예제 #2
0
파일: run_na.py 프로젝트: buret/pylmflib
# Add pylmflib/ folder to path
sys.path.append(user_path + '..')

# Create result folder
if not os.path.exists(user_path + "na/result"):
    os.mkdir(user_path + "na/result")

# Import LMF library
import pylmflib

# Import user customized configuration
from setting import tex_eng, tex_fra, items, classify_lexicon

# Read user configuration
lexical_resource = pylmflib.read_config(user_path + "na/config.xml")

# Read MDF file, generate UID and set lexicon identifier
os.system("python " + user_path + "../pylmflib/utils/eol/eol.py -i " + user_path + "na/Dictionary.txt -o " + user_path + "na/result/dictionary-eol.txt")
os.system("python " + user_path + "../pylmflib/utils/uid/uid.py -i " + user_path + "na/result/dictionary-eol.txt -o " + user_path + "na/result/dictionary-uid.txt")
lexical_resource = pylmflib.read_mdf(id="na")

# Classify lexicon
(xml_order, xml_type) = pylmflib.read_sort_order(user_path + "na/sort_order.xml")
classify_lexicon(lexical_resource.get_lexicon("na"), xml_order, xml_type)

# Generate tables
os.system("python " + user_path + "../pylmflib/utils/tables/tables.py -i " + user_path + "na/Dictionary.txt -e " + user_path + "na/result/table_eng.tex -f " + user_path + "na/result/table_fra.tex")

# Write LaTeX files
pylmflib.write_tex(lexical_resource, user_path + "na/result/dictionary_eng.tex", preamble=user_path + "na/preamble.tex", introduction=user_path + "na/introduction_eng.tex", lmf2tex=tex_eng, items=items, sort_order=xml_order, tables=[user_path + "na/result/table_eng.tex"], title="Online Na-English-Chinese-French Dictionary (version 1.0)")