Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neeme Kahusk
Lightewn
Commits
a036ea6f
Commit
a036ea6f
authored
Mar 06, 2015
by
Neeme Kahusk
Browse files
translation tables
parent
e296dd2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/visdic.py
View file @
a036ea6f
...
...
@@ -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'
]
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment