Commit aeb45f60 authored by Neeme Kahusk's avatar Neeme Kahusk Committed by Neeme Kahusk

lexicon attribs

parent 1d577ca7
......@@ -11,8 +11,11 @@ from pathlib import Path
from lxml import etree
def read2xml(read: list) -> etree._ElementTree:
root = etree.Element('LEXICON')
def lex_attrs(name: str = None, version: str = None, language: str = None) -> dict:
return {'name':name, 'version':version, 'language': language}
def read2xml(read: list, lexattrs: dict = {}) -> etree._ElementTree:
root = etree.Element('LEXICON', lexattrs)
parent = root
level = -1
attrs = {}
......@@ -59,16 +62,20 @@ def main():
parser = argparse.ArgumentParser(description='Converts EuroWordNet file from Polaris I/O to XML file.')
parser.add_argument('infile')
parser.add_argument('outfile')
parser.add_argument('-n', '--lexname', default=None)
parser.add_argument('-v', '--lexver', default=None)
parser.add_argument('-l', '--language', default=None)
args = parser.parse_args()
la = lex_attrs(args.lexname, args.lexver, args.language)
with open(args.infile) as f:
sisu = [parse_line(x) for x in f.readlines()]
#print(read2xml(sisu))
tulem = etree.tounicode(read2xml(sisu), pretty_print=True)
print(tulem)
#for i in sisu:
# print(i)
tulem = etree.tounicode(read2xml(sisu, la), pretty_print=True)
with open(args.outfile,'w') as g:
g.write(tulem)
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment