Commit 4e35d08d authored by Neeme Kahusk's avatar Neeme Kahusk
Browse files

translation tables

parent a9543209
......@@ -22,6 +22,10 @@ from lxml import etree
from settings import PWN_PATH
from settings import FIN_PATH
TABLE_FILENAMES = {'adj':'fin2pwn-adj.txt','adv':'fin2pwn-adv-txt',
'noun':'fin2pwn-noun.txt','verb':'fin2pwn-verb.txt'}
POINTER_SYMBOLS = { # (symbol, pos):
('!','n'):{'gloss':'Antonym','vis':'antonym'},
('@','n'):{'gloss':'Hypernym','vis':'hypernym'},
......@@ -104,6 +108,14 @@ POINTER_SYMBOLS = { # (symbol, pos):
}
def read_tr_table(filename):
"""Reads file from filename, returns table
"""
f = open(filename,'r')
content = map(lambda x: x.strip().split(':'),f.readlines())
f.close()
return content
def deadj(iStr):
"""Remove part in parentheses (used at adjectives)
"""
......@@ -119,8 +131,12 @@ def translate(orig,table=None):
"""Translation of orig to replacement in table
"""
if table:
return map(lambda x: x[-1],
filter(lambda y: y[0]==orig,table))[0]
t = map(lambda x: x[-1],
filter(lambda y: y[0]==orig,table))
if t:
return t[0]
else:
return 'NA'
else:
return orig
......@@ -580,11 +596,11 @@ def oldermain():
transD = None
if options.trans:
f = open(options.trans, 'r')
transD = map(lambda x: x.strip().split(':'),f.readlines())
f.close()
# print transD
# if options.trans:
# f = open(options.trans, 'r')
# transD = map(lambda x: x.strip().split(':'),f.readlines())
# f.close()
# # print transD
oList = wnparser(PWN_PATH,options.pos,
int(options.start),int(options.end)
......
Supports Markdown
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