def convert_lexicon(): from kwaras.conf import config from kwaras.formats.lift import Lift from kwaras.process import liftadd config.ConfigWindow("lexicon.cfg", parts=["EAFL"]) cfg = json.load(open("lexicon.cfg")) dir_name = cfg["EAFL_DIR"] inf_name = cfg["LIFT"] base, ext = os.path.splitext(inf_name) if ext == ".lift": print "Exposing GUID as field in", inf_name # update GUID field in lexicon lift = Lift(inf_name) lift = liftadd.exposeGuid(lift) lift.write(os.path.join(dir_name, base + "-guid.lift")) # add allomorphs to LIFT file print "Adding allomorphs to", inf_name lift = liftadd.addRarAllomorphs(lift) # dump the LIFT data to a new file outf_name = os.path.join(dir_name, base + "-added.lift") lift.write(outf_name) print "Data written to", outf_name print "Converting LIFT format to EAFL format" eafl_name = os.path.join(dir_name, base + "-import.eafl") lift.toEAFL(eafl_name) print "Data written to", eafl_name else: tkMessageBox.showerror(title="Wrong format.", message="The selected file is not a LIFT lexicon file.")
import json from kwaras.conf import config from kwaras.formats.lift import Lift from kwaras.process import liftadd config.ConfigWindow("lexicon.cfg",parts=["EAFL"]) cfg = json.load(open("lexicon.cfg")) dir_name = cfg["EAFL_DIR"] inf_name = cfg["LIFT"] base, ext = os.path.splitext(inf_name) if ext == ".lift": print "Exposing GUID as field in", inf_name # update GUID field in lexicon lift = Lift(inf_name) lift = liftadd.exposeGuid(lift) lift.write(os.path.join(dir_name, base + "-guid.lift")) # add allomorphs to LIFT file print "Adding allomorphs to", inf_name lift = liftadd.addRarAllomorphs(lift) # dump the LIFT data to a new file outf_name = os.path.join(dir_name, base + "-added.lift") lift.write(outf_name) print "Data written to", outf_name print "Converting LIFT format to EAFL format" eafl_name = os.path.join(dir_name, base + "-import.eafl") lift.toEAFL(eafl_name) print "Data written to", eafl_name
lift.appendVariant(eid, f) return lift if __name__ == "__main__": import sys import os dirname = os.path.dirname(sys.argv[-1]) for fname in os.listdir(dirname): base, ext = os.path.splitext(fname) if ext == ".lift": print "Exposing GUID as lexeme field in", fname lift = Lift(os.path.join(dirname, fname)) lift = expose_guid(lift) lift.write(os.path.join(dirname, base + "-guid.lift")) print "Data written to", os.path.join(dirname, base + "-guid.lift") print "Adding allormorphs to", fname # add allomorphs to LIFT file lift = add_allomorphs(lift) # dump the LIFT data to a new file lift.write(os.path.join(dirname, base + "-added.lift")) print "Data written to", os.path.join(dirname, base + "-added.lift") print "Converting LIFT format to EAFL format" lift.toEAFL(os.path.join(dirname, base + "-import.eafl")) print "Data written to", os.path.join(dirname, base + "-import.eafl") else: