Commit a036ea6f authored by Neeme Kahusk's avatar Neeme Kahusk
Browse files

translation tables

parent e296dd2f
......@@ -89,8 +89,6 @@ POINTER_SYMBOLS = { # (symbol, pos):
('-r','a'):{'gloss':'Member of this domain - REGION',
'vis':'member_of_region'},
# The pointer_symbol s for adverbs are:
('!','r'):{'gloss':'Antonym','vis':'antonym'},
......@@ -116,10 +114,14 @@ def read_tr_table(filename):
f.close()
return content
# Get translation tables
TR_TABLES = {}
for i in TABLE_FILENAMES:
TR_TABLES[i]=read_tr_table(TABLE_FILENAMES[i])
def deadj(iStr):
"""Remove part in parentheses (used at adjectives)
"""
if iStr.count('<'):
return iStr[0:iStr.index('<')]
elif iStr.count('('):
......@@ -127,9 +129,11 @@ def deadj(iStr):
else:
return iStr
def translate(orig,table=None):
def translate(orig,table=None,tabledict=None,pos=None):
"""Translation of orig to replacement in table
"""
if not table and tabledict and pos:
table = tabledict[pos]
if table:
t = map(lambda x: x[-1],
filter(lambda y: y[0]==orig,table))
......@@ -525,13 +529,15 @@ def make_visdic_xml(dataDict,xml,translation=None):
try:
ilrText = '{}-{}-{}'.format(ID_PREFIX,
translate(j['synset_offset'],
translation),
tabledict=TR_TABLES,
pos=j['pos']),
j['pos']
)
except ValueError:
ilrText = '%s-%s-%s' % (ID_PREFIX,
translate(j['synset_offset'],
translation),
tabledict=TR_TABLES,
pos=j['pos']),
j['pos']
)
......
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