Subversion Repositories LCARS

Compare Revisions

Last modification

Ignore whitespace Rev 298 → Rev 300

/trunk/tools/eazytrans/vuh.py
6,21 → 6,14
@author: Thomas 'PointedEars' Lahn <mail@PointedEars.de>
'''
from sys import argv, stderr
from re import findall, DOTALL, match, sub, compile, \
escape, search
from re import findall, compile
from os.path import basename
from functools import cmp_to_key
from Dictionary import Dictionary, dmsg, \
sort_dict_alnum_english_key
from Dictionary import dmsg, sort_dict_alnum_english_key
from VulcanDictionary import VulcanDictionary, Text
 
dictionary = {}
 
prepositions = {
"fi'": 'on',
"na'": 'at|to',
"t'": 'of'
}
 
def cli_help():
print('Usage: {0} TEXT...'.format(basename(argv[0])))
 
54,63 → 47,7
 
return cmp_to_key(sort_dict_alnum_vulcan)
 
class VulcanDictionary (Dictionary):
"""
"""
def translate (self, phrase, search_prefix=True, search_plural=True):
"""
:param phrase:
:type phrase:
:param search_prefix:
:type search_prefix:
:param search_plural:
:type search_plural:
"""
translation = super().translate(phrase)
if translation is not None:
return translation
else:
expr_translation = self.translate_expression(phrase)
if expr_translation is not None:
return expr_translation
 
if search_prefix:
# find prefix
for preposition in prepositions:
prefix = match(escape(preposition), phrase)
if prefix is not None:
prefix_translation = self.translate(prefix.group(0))
if prefix_translation is not None:
tail = sub(preposition, '', phrase)
tail_translation = self.translate(tail, search_prefix=False)
if tail_translation is not None:
return [prefix_translation, tail_translation]
elif search_plural:
# find plural
suffix = search(r'lar$', phrase)
if suffix is not None:
head = sub(r'lar$', '', phrase)
head_translation = self.translate(head, search_prefix=False, search_plural=False)
if head_translation is not None:
head_translation = dict(head_translation)
head_translation['en'] += ' (pl.)'
return head_translation
 
return None
 
def clean_entry(self, phrase):
"""
Replace GV Media Script parens with FSE parens
:param phrase:
:type phrase:
"""
return sub(
r'(\([^)]*\))|\|([^|)]+)\|',
lambda m: '({0})'.format(m.group(2)) if m.group(2) else m.group(1),
phrase)
 
if __name__ == '__main__':
if len(argv) < 2:
print('Nothing to translate.', end='\n\n', file=stderr)
123,60 → 60,30
dictionary.load('vuh-gol-en.dict.zdb.txt', 'vuh')
dictionary.clean()
 
# try:
# for phrase, data in OrderedDict(sorted(
# dictionary.items(),
# key=get_sort_dict_alnum_vulcan_key()
# )).items():
# print(phrase, "=", data)
# except BrokenPipeError:
# pass
# try:
# for phrase, data in OrderedDict(sorted(
# dictionary.items(),
# key=get_sort_dict_alnum_vulcan_key()
# )).items():
# print(phrase, "=", data)
# except BrokenPipeError:
# pass
 
text = Text(text)
 
dmsg("text:", text, min_level=2)
sentences = findall(r'(?!\s+)(?:.+?\.{1,3}|.+$)', text, DOTALL)
dmsg("sentences:", sentences, min_level=2)
for sentence in sentences:
dmsg("sentence:", sentence, min_level=2)
dmsg("text:", text.__repr__(), min_level=2)
 
clauses = findall(r'(?!\s+)(?:.+?(?:\s+-\s*|\s*[–—]\s*|\.{1,3}|.+$))', sentence, DOTALL)
dmsg("clauses:", clauses, min_level=2)
for clause in clauses:
dmsg("clause:", clause, min_level=2)
text.translate(dictionary)
 
words = findall(r'[^\s.]+', clause)
dmsg("words:", words, min_level=2)
 
offset = 0
while offset < len(words):
translation = None
 
for i in range(len(words), offset, -1):
dmsg("words[{0}:{1}] = {2}".format(offset, i, words[offset:i]), min_level=2)
phrase = ' '.join(words[offset:i])
 
dmsg("phrase:", phrase, min_level=2)
 
translation = dictionary.translate(phrase)
 
if translation is not None:
dmsg("phrase-translation:", translation, min_level=2)
dmsg("words[{0}:{1}] = [\"{2}\"]".format(offset, i, translation), min_level=2)
words[offset:i] = [translation]
offset += i - offset
break
 
if translation is None:
dmsg("phrase-translation:", translation, min_level=2)
offset += 1
 
dmsg("words-translation:", words, min_level=2)
dmsg("words-translation-reduced:",
list(map(
lambda word:
word['en']
if (hasattr(word, "get") and word.get('en', None) is not None)
else word,
words)),
min_level=2)
# for key, value in dictionary._expressions.items():
# dmsg(key, value, min_level=3)
# dmsg("words-translation:", words, min_level=2)
# dmsg("words-translation-reduced:",
# list(map(
# lambda word:
# word['en']
# if (hasattr(word, "get") and word.get('en', None) is not None)
# else word,
# words)),
# min_level=2)
# for key, value in dictionary._expressions.items():
# dmsg(key, value, min_level=3)
/trunk/tools/eazytrans/Dictionary.py
13,21 → 13,19
 
debug_level = 2
 
def dmsg(*args, **kwargs):
if not hasattr(kwargs, 'min_level') or kwargs['min_level'] is None:
kwargs['min_level'] = 1
 
if not hasattr(kwargs, 'file'):
def dmsg (*args, **kwargs):
if not kwargs.get('file'):
kwargs['file'] = stderr
 
if debug_level >= kwargs['min_level']:
del kwargs['min_level']
min_level = kwargs.pop('min_level', 1)
 
if debug_level >= min_level:
print(*args, **kwargs)
 
def sort_dict_alnum_english_key(phrase):
def sort_dict_alnum_english_key (phrase):
return sub(r'\{(.+)\}', r'\1', phrase[0]).lower()
 
class Dictionary(dict):
class Dictionary (dict):
"""
A Dictionary (not to be confused with its ancestor, dict)
represents a word dictionary stored in a file.
37,7 → 35,7
_keys = "ipa|en|lit|pos|com|tag|ex"
_expressions = {}
 
def load (self, dictionary_file, language_key='en'):
def load (self, dictionary_file, keys=None, language_key=None):
"""
Loads a word dictionary from a file.
:param dictionary_file:
45,8 → 43,12
:param language_key:
:type language_key:
"""
self._language_key = language_key
if keys is not None:
self._keys = keys
 
if language_key is not None:
self._language_key = language_key
 
dmsg('Loading dictionary '.format(dictionary_file), end='', min_level=1)
 
chdir(dirname(realpath(__file__)))
60,6 → 62,7
 
if pickle_mtime is None or stat(dictionary_file).st_mtime > pickle_mtime:
dmsg('from {0} ...'.format(dictionary_file), end='', min_level=1)
 
phrase = None
key = None
value = None
101,11 → 104,14
self[phrase][key] = ' '.join(value)
 
dmsg('\nSaving pickle {0} ...'.format(pickle_file), end='', min_level=1)
 
# TODO: Pickle should only contain strings to be small
with open(pickle_file, mode='wb') as f: dump(self, f)
 
dmsg(' done.', min_level=1)
else:
dmsg('from {0} ...'.format(pickle_file), end='', min_level=1)
 
with open(pickle_file, mode='rb') as f: pickle = load(f)
for key, value in pickle.items():
self[key] = value
/trunk/tools/eazytrans/vuh-gol-en.dict.zdb.txt
1,5 → 1,5
# Golic Vulcan (GV):Federation Standard English (FSE)
#
#
# Legend
# {Danaya}
# ("Explanation"):
145,7 → 145,7
# ("Close-follow entries of-this dictionary format established
# by-Klingonska Akademien [KA] for-online-version
# of-'Pocket-Dictionary Klingon' <http://klingonska.org/dict/>.
# See [hon. imp.] on-website of-them for-details.")
# See! [hon.] on-website of-them for-details.")
#
# The format of this dictionary differs in that it uses “vuh”,
# for Vulcan, instead of “tlh”, for Klingon, adds the “ipa” key,
158,7 → 158,7
# ("Have format of-this dictionary difference – use of->vuh< -
# for-language Vulcan – instead of->tlh< - for-Klingon – add
# key >ipa< - use abbrevations for-key >pos< for-small-keeping
# size of-file and different-abbrevations [below-see (hon. imp.)] :")
# size of-file and different-abbrevations [below-see! (hon.)] :")
#
# vuh: {original(required|alternative) (optional part)} (required)
# ipa: IPA transcription (optional)
210,14 → 210,17
#
# Different from the KA format, entries are indented to signify
# derivation, so that software can mark common word-roots
# automatically. The optional part of the original may contain
# automatically. Use two spaces per indentation level.
# The optional part of the original may contain
# affixes that can be omitted, or give an abbreviation.
# {Natyan na'yidor t'KA - pugas-dvun-tor svinlar glantokau
# sakazun - shatik kup-ulidau tumak ka-zhit-girlar.
# Is'voh dah-ret na'vok t'gas-dvun.
# Kup-tuhlau dvelik krus t'tvesh-vel tereklar kup-puyenik
# il tanilau zhipenaya.}
# ("Difference to-format of-KA - be-indented entries signify
# derivation - automatically can-mark program same-word-roots.
# derivation - automatically can-mark program same-word-root.
# Use! two-space for-level of-indentation.
# Can-contain optional part of-original affixes can-be-forgotten
# or give abbreviation.")
#
326,7 → 329,7
# Isha ri bolau zhit-dunap-gir nam-tor kim-krus t'terti-zhit.}
# ("Only-if all-criteria superordered same - be-sorted entries
# to-FSE-alphabet | not alphabet of-Modern-Golic-Vulcan
# to-help students. | Notice [hon. imp.] that verb-forms of-nouns -
# to-help students. | Notice! [hon.] that verb-forms of-nouns -
# although modifying e.g. with->~au<, and combining with->-tor< -
# be-sorted before-other-forms modifying and combining because have
# they more-strong root-relation.
338,7 → 341,7
# {Fayei t'ta - kuv ri kup tal-tor du mesukh t'terti-zhit
# na'svinlar palikaun k'zun t'zhit - viglazha'voh svin t'nel-gir.}
# ("Because of-that - if not can find you translation of-compound-word
# at-entries beginning with-letter of-word - into-look [hon. imp.]
# at-entries beginning with-letter of-word - into-look! [hon.]
# entry of-main-root.")
#
# The following abbreviations have been used:
497,7 → 500,7
# ka-tvahik iyi-zhit na'isan ek'gadik heh
# rivanuk | na'li-fal {wak} svi'rak t'{farr} -
# hi – {kari farr} - {pon farr} ∴}
# ("too-old [ word ] - instead-use [hon. imp.]
# ("too-old [ word ] - instead-use! [hon.]
# synonymous contemporary-word for-usage diurnal and
# non-ceremonial | for-example {wak} instead of-{farr} -
# but : {kari farr} - {pon farr} etc.")
711,7 → 714,7
com: not in GV-FSE
 
vuh: {abrash}
ipa: ɑ‿'braʃ
ipa: ɑ‿'brɑʃ
en: <flood>
pos: n.
 
769,7 → 772,7
def: FSE-GV
com: not in GV-FSE
 
vuh: {abu(')~)}
vuh: {abu(')~}
en: <up>
 
vuh: {abu-tor}
776,12 → 779,12
en: <erect>, <put up>
 
vuh: {abu'le}
ipa: - ' -
ipa: ɑ‿'bu‿le
en: <upward(s)>
com: from CLGV {apu'leh} and AGV {ápuullh}
 
vuh: {abulau}
ipa: - - '
ipa: ɑ‿bu‿'lau
en: <increase>
pos: v.
 
10693,6 → 10696,7
vuh: {gas-dvun-tor}
en: <indent>
lit: <right>-<move>
pos: v.
def: PE
 
vuh: {pugas-dvun-tor}
14837,6 → 14841,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {huhrsauyik}
en: <practical>
pos: adj.
def: PE
 
vuh: {huhsh}
ipa: ,
en: <cough>
15673,7 → 15682,7
 
vuh: {ish}
en: <that>
pos: adj.
pos: det.
def: FSE-GV
com: not in GV-FSE
 
17804,6 → 17813,11
en: <bring>
pos: v.
 
vuh: {nukatau}
en: <bring down>, <inflict>
pos: v.
def: PE
 
vuh: {sakatau}
en: <enhance>, <bring out>, <implement>
def: GV-FSE; <implement> by PE
17814,7 → 17828,7
 
vuh: {sakatausu}
en: <implementor>
lit: implementperson
lit: <implement><person>
def: PE
 
vuh: {vikatau}
19063,6 → 19077,11
en: <direct>
pos: adj.
 
vuh: {rikhar(-~|ik)}
en: <indirect>
pos: adj.
def: PE
 
vuh: {khar-el'taranaya}
en: <direct manipulation>
def: FSE-GV
28036,11 → 28055,27
en: <reach>
pos: v.
 
vuh: {pulayau}
ipa: - - '
en: <be present>
pos: v.
vuh: {sapulau}
en: <reach out>
pos: v.
def: PE
 
vuh: {pulaya}
en: <reach>
pos: n.
def: PE
 
vuh: {pulayan}
en: <reaching>
pos: n.
def: PE
 
vuh: {pulayau}
ipa: - - '
en: <be present>
pos: v.
com: but <presence> {la'es}; cf. {pulayan}
 
vuh: {pulu-kur}
en: <lavender>
tag: col.
31618,7 → 31653,7
 
vuh: {ta}
en: <that>, <which>, <who> (not a question word)
pos: conj.
pos: conj., pron.
tag: MGV
 
vuh: {ta'a}
31860,6 → 31895,11
en: <ideal>
pos: n.
 
vuh: {tangu(-~|yik)}
en: <ideal>
pos: adj.
def: PE
 
vuh: {tanilau}
en: <provide>, <supply>
pos: v.
44748,11 → 44788,6
def: FSE-GV
com: not in GV-FSE
 
vuh: {papulau}
en: <roam>
def: FSE-GV
com: not in GV-FSE
 
vuh: {paresh-tor}
en: <occur>
def: FSE-GV
46903,16 → 46938,16
def: FSE-GV
com: not in GV-FSE
 
vuh: {plomik shur}
en: <vegetable soup>
def: FSE-GV
com: not in GV-FSE
 
vuh: {plom (n., anc.); plomik (adj.)}
en: <vegetable>
def: FSE-GV
com: not in GV-FSE
 
vuh: {plomik shur}
en: <vegetable soup>
def: FSE-GV
com: not in GV-FSE
 
vuh: {plo-mokevik vukh-slaun}
en: <parametallic hull plating>
def: FSE-GV
47830,6 → 47865,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {papulau}
en: <roam>
def: FSE-GV
com: not in GV-FSE
 
vuh: {pulayau}
en: <be present>
def: FSE-GV
50439,11 → 50479,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {rirun-tor}
en: <daydream>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rirun-tor}
en: <daydream>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {risa-guv-aitlun}
en: <satyriasis>
50597,18 → 50637,18
def: FSE-GV
com: not in GV-FSE
 
vuh: {rishihal-tor}
en: <yaw>
pos: v.
tag: aero.
def: FSE-GV
com: not in GV-FSE
vuh: {rishihal-tor}
en: <yaw>
pos: v.
tag: aero.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rishihal-khardvun}
en: <yaw maneuver>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {rishihal-khardvun}
en: <yaw maneuver>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rish-kas-vikantau}
en: <cross-pollinate>
50667,16 → 50707,16
def: FSE-GV
com: not in GV-FSE
 
vuh: {rish-tor}
en: <mix>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rish-tor}
en: <mix>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rish-tash|ek|}
en: <mixture control>
def: FSE-GV
com: not in GV-FSE
vuh: {rish-tash|ek|}
en: <mixture control>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rish-tor}
en: <survive>
50853,11 → 50893,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {ritishaya}
en: <dislike>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {ritishaya}
en: <dislike>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {ritorupik}
en: <passive>
51418,19 → 51458,19
def: FSE-GV
com: not in GV-FSE
 
vuh: {riyeht-staya}
en: <murder>
lit: <wrong>-<killing>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {riyeht-staya}
en: <murder>
lit: <wrong>-<killing>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {kaisu-riyeht-staya}
en: <fratricide>
lit: <sibling>-<murder>
def: FSE-GV
com: not in GV-FSE
see: {kaisu}
vuh: {kaisu-riyeht-staya}
en: <fratricide>
lit: <sibling>-<murder>
def: FSE-GV
com: not in GV-FSE
see: {kaisu}
 
vuh: {riyeht-vikayek}
en: <false alarm>
51510,11 → 51550,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {rok-tor}
en: <hope>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rok-tor}
en: <hope>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {roman(-~|ik)}
en: <roman>
51528,86 → 51568,86
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-halan}
en: <farewell>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {rom-halan}
en: <farewell>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom'lashan} (TGV), {farmahn} (MGV)
en: <welcome>
lit: <good><arrival> (TGV)
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {rom'lashan} (TGV), {farmahn} (MGV)
en: <welcome>
lit: <good><arrival> (TGV)
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom'lasha} (TGV), {farmah} (MGV)
en: <welcome>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rom'lasha} (TGV), {farmah} (MGV)
en: <welcome>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {romosh}
en: <quality>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {romosh}
en: <quality>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {romosh-tash}
en: <quality control>
def: FSE-GV
com: not in GV-FSE
vuh: {romosh-tash}
en: <quality control>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rompotau}
en: <maintain>
def: FSE-GV
com: not in GV-FSE
vuh: {rompotau}
en: <maintain>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rompotau-zup-shal}
en: <maintenance shop>
def: FSE-GV
com: not in GV-FSE
vuh: {rompotau-zup-shal}
en: <maintenance shop>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rompotaya}
en: <maintenance>
def: FSE-GV
com: not in GV-FSE
vuh: {rompotaya}
en: <maintenance>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-ralashik}
en: <euphonious>
def: FSE-GV
com: not in GV-FSE
vuh: {rom-ralashik}
en: <euphonious>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-skaunik}
en: <eupeptic>
def: FSE-GV
com: not in GV-FSE
vuh: {rom-skaunik}
en: <eupeptic>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-stau}
en: <euthanize>
def: FSE-GV
com: not in GV-FSE
vuh: {rom-stau}
en: <euthanize>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-staya}
en: <euthanasia>
def: FSE-GV
com: not in GV-FSE
vuh: {rom-staya}
en: <euthanasia>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-tanaf}
en: <fine art>
def: FSE-GV
com: not in GV-FSE
vuh: {rom-tanaf}
en: <fine art>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rom-va'asaya}
en: <facsimile> (copy), <copy>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {rom-va'asaya}
en: <facsimile> (copy), <copy>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {raf-glakuv-sasaya}
en: <facsimile> (fax), <fax>
def: FSE-GV
com: not in GV-FSE
vuh: {raf-glakuv-sasaya}
en: <facsimile> (fax), <fax>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ro'ribet}
en: <report>
51615,10 → 51655,10
def: FSE-GV
com: not in GV-FSE
 
vuh: {ro'ribetsu}
en: <reporter>
def: FSE-GV
com: not in GV-FSE
vuh: {ro'ribetsu}
en: <reporter>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rostalik}
en: <subtle>
51632,92 → 51672,92
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubai}
en: <change>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rubai}
en: <change>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubefa}
en: <pupa>
def: FSE-GV
com: not in GV-FSE
vuh: {rubefa}
en: <pupa>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubihalan}
en: <transition>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {rubihalan}
en: <transition>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubihalan-meilak}
en: <transition element>
def: FSE-GV
com: not in GV-FSE
vuh: {rubihalan-meilak}
en: <transition element>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubihalat(-~|ik)}
en: <transitional>
pos: adj.
def: FSE-GV
com: not in GV-FSE
vuh: {rubihalat(-~|ik)}
en: <transitional>
pos: adj.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubilau}
en: <adapt>
def: FSE-GV
com: not in GV-FSE
vuh: {rubilau}
en: <adapt>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubilauk}
en: <flexible> (adaptable)
def: FSE-GV
com: not in GV-FSE
vuh: {rubilauk}
en: <flexible> (adaptable)
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubilaya}
en: <adaptation>
def: FSE-GV
com: not in GV-FSE
vuh: {rubilaya}
en: <adaptation>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubilau-saya}
en: <adaptive radiation>
def: FSE-GV
com: not in GV-FSE
vuh: {rubilau-saya}
en: <adaptive radiation>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubilau-vel}
en: <adapter>
def: FSE-GV
com: not in GV-FSE
vuh: {rubilau-vel}
en: <adapter>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubilau-zehlaya}
en: <adaptive array>
def: FSE-GV
com: not in GV-FSE
vuh: {rubilau-zehlaya}
en: <adaptive array>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubitau}
en: <alter>, <modify>
def: FSE-GV
com: not in GV-FSE
vuh: {rubitau}
en: <alter>, <modify>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rubitau(-~|k)}
en: <modifying>
pos: adj.
vuh: {rubitau(-~|k)}
en: <modifying>
pos: adj.
 
vuh: {rubitaya}
en: <alteration>, <modification>
def: FSE-GV
com: not in GV-FSE
vuh: {rubitaya}
en: <alteration>, <modification>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruboch}
en: <sorcerer>
def: FSE-GV
com: not in GV-FSE
vuh: {ruboch}
en: <sorcerer>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruboch-tanaf}
en: <sorcery>
def: FSE-GV
com: not in GV-FSE
vuh: {ruboch-tanaf}
en: <sorcery>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rub-zhit}
en: <adjective>
def: FSE-GV
com: not in GV-FSE
vuh: {rub-zhit}
en: <adjective>
def: FSE-GV
com: not in GV-FSE
 
vuh: {tedvunik}
en: <flexible> (pliable/pliant)
51736,11 → 51776,11
def: FSE-GV
com: falsely v.; not in GV-FSE
 
vuh: {rufai}
en: <benefit>
pos: v.
def: FSE-GV
com: falsely n.; not in GV-FSE
vuh: {rufai}
en: <benefit>
pos: v.
def: FSE-GV
com: falsely n.; not in GV-FSE
 
vuh: {ruhm}
en: <even>
51748,10 → 51788,10
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruhm-reh}
en: <even though>
def: FSE-GV
com: not in GV-FSE
vuh: {ruhm-reh}
en: <even though>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rukau}
en: <bounce>
51771,11 → 51811,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruk-tor}
en: <egress>, <exit>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {ruk-tor}
en: <egress>, <exit>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rukhaul}
en: <rebound>
51783,16 → 51823,16
def: FSE-GV
com: not in GV-FSE
 
vuh: {rukhaul-tor}
en: <rebound>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rukhaul-tor}
en: <rebound>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rukhaul s'rasath t'dvun-le-sumatra}
en: <glacial rebound>
def: FSE-GV
com: not in GV-FSE
vuh: {rukhaul s'rasath t'dvun-le-sumatra}
en: <glacial rebound>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruk-ikun}
en: <exit cone>
51825,26 → 51865,26
def: FSE-GV
com: not in GV-FSE
 
vuh: {ru'lut-masu} (TGV), {ru'lumu} (MGV)
en: <saliva>
lit: <mouth>-<water> (TGV)
def: FSE-GV
com: not in GV-FSE
vuh: {ru'lut-masu} (TGV), {ru'lumu} (MGV)
en: <saliva>
lit: <mouth>-<water> (TGV)
def: FSE-GV
com: not in GV-FSE
 
vuh: {ru'lut-pi'nafek}
en: <buccal gland>
def: FSE-GV
com: not in GV-FSE
vuh: {ru'lut-pi'nafek}
en: <buccal gland>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ru'lut-sai-mesklam}
en: <napkin holder>
def: FSE-GV
com: not in GV-FSE
vuh: {ru'lut-sai-mesklam}
en: <napkin holder>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ru'lut-sai}
en: <napkin>
def: FSE-GV
com: not in GV-FSE
vuh: {ru'lut-sai}
en: <napkin>
def: FSE-GV
com: not in GV-FSE
 
vuh: {runelau}
en: <cramp>
51852,11 → 51892,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {runelaya}
en: <cramp>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {runelaya}
en: <cramp>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {runem}
en: <grab>, <grapple>
51864,16 → 51904,16
def: FSE-GV; <grapple> by PE from {runem-kik}
com: not in GV-FSE
 
vuh: {runem-tor}
en: <grab>, <grapple>
pos: v.
def: FSE-GV; <grapple> by PE from {runem-kik}
com: not in GV-FSE
vuh: {runem-tor}
en: <grab>, <grapple>
pos: v.
def: FSE-GV; <grapple> by PE from {runem-kik}
com: not in GV-FSE
 
vuh: {runem-kik}
en: <grappling iron>
def: FSE-GV
com: not in GV-FSE
vuh: {runem-kik}
en: <grappling iron>
def: FSE-GV
com: not in GV-FSE
 
vuh: {runev}
en: <spasm>
51887,11 → 51927,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {run-tor}
en: <dream>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {run-tor}
en: <dream>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushan}
en: <conversion>
51898,47 → 51938,47
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushanek}
en: <converter>
def: FSE-GV
com: not in GV-FSE
vuh: {rushanek}
en: <converter>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushan-klai}
en: <conversion factor>
def: FSE-GV
com: not in GV-FSE
vuh: {rushan-klai}
en: <conversion factor>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushan-nazh}
en: <conversion gain>
def: FSE-GV
com: not in GV-FSE
vuh: {rushan-nazh}
en: <conversion gain>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushan-pak}
en: <conversion loss>
def: FSE-GV
com: not in GV-FSE
vuh: {rushan-pak}
en: <conversion loss>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushan-tor}
en: <convert>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {rushan-tor}
en: <convert>
pos: v.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushansu}
en: <convert>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {rushansu}
en: <convert>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {rushan-tavat}
en: <conversion ratio>
def: FSE-GV
com: not in GV-FSE
vuh: {rushan-tavat}
en: <conversion ratio>
def: FSE-GV
com: not in GV-FSE
 
vuh: {rush-sasayek}
en: <transducer>
def: FSE-GV
com: not in GV-FSE
vuh: {rush-sasayek}
en: <transducer>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruskarau}
en: <grasp>
51946,16 → 51986,16
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruskaraya}
en: <grasp>
pos: n.
def: FSE-GV
com: not in GV-FSE
vuh: {ruskaraya}
en: <grasp>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruskarayek}
en: <forceps>
def: FSE-GV
com: not in GV-FSE
vuh: {ruskarayek}
en: <forceps>
def: FSE-GV
com: not in GV-FSE
 
vuh: {ruski(-~|k)}
en: <Russian>
51984,20 → 52024,20
def: FSE-GV
com: not in GV-FSE
 
vuh: {sa'adek-elakh}
en: <elevator cable>
def: FSE-GV
com: not in GV-FSE
vuh: {sa'adek-elakh}
en: <elevator cable>
def: FSE-GV
com: not in GV-FSE
 
vuh: {sa'adek-ramev}
en: <elevator shaft>
def: FSE-GV
com: not in GV-FSE
vuh: {sa'adek-ramev}
en: <elevator shaft>
def: FSE-GV
com: not in GV-FSE
 
vuh: {sa'adek-su-natuhn}
en: <elevator car>
def: FSE-GV
com: not in GV-FSE
vuh: {sa'adek-su-natuhn}
en: <elevator car>
def: FSE-GV
com: not in GV-FSE
 
vuh: {sa'a-dvun}
en: <autonomic movement>
53045,11 → 53085,6
def: FSE-GV
com: not in GV-FSE
 
vuh: {sakatau}
en: <bring out>, <enhance>
def: FSE-GV
com: not in GV-FSE
 
vuh: {sakataya}
en: <enhancement>
def: FSE-GV
53413,10 → 53448,10
def: FSE-GV
com: not in GV-FSE
 
vuh: {salesh(-~|ik)}
en: <efferent>
def: FSE-GV
com: not in GV-FSE
vuh: {salesh(-~|ik)}
en: <efferent>
def: FSE-GV
com: not in GV-FSE
 
vuh: {salim}
en: <feature>
54713,15 → 54748,15
def: FSE-GV
com: not in GV-FSE
 
vuh: {satorvau}
en: <result>
pos: v.
def: PE
vuh: {satorvau}
en: <result>
pos: v.
def: PE
 
vuh: {satorvan}
en: <resulting>
pos: ger.
def: PE
vuh: {satorvan}
en: <resulting>
pos: ger.
def: PE
 
vuh: {sa'tra}
en: <out there>
56516,13 → 56551,14
 
vuh: {sha'ves-yokulan}
en: <cannibalism>
lit: <own><kind>-<eating>
def: FSE-GV
com: not in GV-FSE
 
vuh: {sha'ves-yokulsu}
en: <cannibal>
def: FSE-GV
com: not in GV-FSE
vuh: {sha'ves-yokulsu}
en: <cannibal>
def: FSE-GV
com: not in GV-FSE
 
vuh: {shaya (n.), shau (v.)}
en: <break>, <fracture>
61941,12 → 61977,6
def: FSE-GV
com: not in GV-FSE
 
vuh: {ta}
en: <that>
pos: conj., pron.
def: FSE-GV
com: not in GV-FSE
 
vuh: {ta'bek}
tag: anc.
en: <drug>
62387,12 → 62417,6
def: FSE-GV
com: not in GV-FSE
 
vuh: {tangu}
en: <ideal>
pos: n.
def: FSE-GV
com: not in GV-FSE
 
vuh: {tangu-sfek}
en: <ideal point>
def: FSE-GV
62979,10 → 63003,11
def: FSE-GV
com: not in GV-FSE
 
vuh: {tehnekon-torsu}
en: <sinner>
def: FSE-GV
com: not in GV-FSE
vuh: {tehnekon-torsu}
en: <sinner>
lit: <against><god>-<do><person>
def: FSE-GV
com: not in GV-FSE
 
vuh: {tehnesaya}
en: <entropy>
70686,11 → 70711,6
def: FSE-GV
com: not in GV-FSE
 
vuh: {vikatau}
en: <bring in>
def: FSE-GV
com: not in GV-FSE
 
vuh: {vikau}
en: <warn>
pos: v.
71194,30 → 71214,32
 
vuh: {vishasplotau}
en: <invade>
lit: <into><land><?>
def: FSE-GV
com: not in GV-FSE
see: {vi}, {shasol}, {plotau}
 
vuh: {vishasplotausu}
en: <invader>
def: FSE-GV
com: not in GV-FSE
 
vuh: {vishasplotaya}
en: <invasion>
def: FSE-GV
com: not in GV-FSE
 
vuh: {vishasplotausu}
en: <invader>
def: FSE-GV
com: not in GV-FSE
vuh: {vishasplotaya}
en: <invasion>
def: FSE-GV
com: not in GV-FSE
vuh: {vishau}
en: <insert>
pos: v.
def: FSE-GV
com: not in GV-FSE
vuh: {vishaya}
en: <insertion>
def: FSE-GV
com: not in GV-FSE
 
vuh: {vishaya}
en: <insertion>
def: FSE-GV
com: not in GV-FSE
 
vuh: {vishital(-~|ik)}
en: <embedded>
pos: adj.
71476,11 → 71498,6
def: FSE-GV
com: not in GV-FSE
 
vuh: {vi}
en: <who>
def: FSE-GV
com: not in GV-FSE
 
vuh: {viyatau}
en: <impregnate>
def: FSE-GV
77891,3 → 77908,5
en: <gadget>, <gizmo>
def: FSE-GV
com: not in GV-FSE
 
# vim: set tabstop=2 shiftwidth=2 expandtab :
/trunk/tools/eazytrans/VulcanDictionary.py
New file
0,0 → 1,174
"""
Created on 15.01.2015
 
@author: pelinux
 
"""
from Dictionary import Dictionary, dmsg
from re import escape, match, sub, search, findall, DOTALL
 
prepositions = {
"fi'": 'on',
"na'": 'at|to',
"t'": 'of'
}
 
class VulcanDictionary (Dictionary):
"""
"""
def translate (self, phrase, search_prefix=True, search_plural=True):
"""
:param phrase:
:type phrase:
:param search_prefix:
:type search_prefix:
:param search_plural:
:type search_plural:
"""
translation = super().translate(phrase)
if translation is not None:
return translation
else:
expr_translation = self.translate_expression(phrase)
if expr_translation is not None:
return expr_translation
 
if search_prefix:
# find prefix
for preposition in prepositions:
prefix = match(escape(preposition), phrase)
if prefix is not None:
prefix_translation = self.translate(prefix.group(0))
if prefix_translation is not None:
tail = sub(preposition, '', phrase)
tail_translation = self.translate(tail, search_prefix=False)
if tail_translation is not None:
return [prefix_translation, tail_translation]
elif search_plural:
# find plural
suffix = search(r'lar$', phrase)
if suffix is not None:
head = sub(r'lar$', '', phrase)
head_translation = self.translate(head, search_prefix=False, search_plural=False)
if head_translation is not None:
head_translation = dict(head_translation)
head_translation['en'] += ' (pl.)'
return head_translation
 
return None
 
def clean_entry(self, phrase):
"""
Replace GV Media Script parens with FSE parens
:param phrase:
:type phrase:
"""
return sub(
r'(\([^)]*\))|\|([^|)]+)\|',
lambda m: '({0})'.format(m.group(2)) if m.group(2) else m.group(1),
phrase)
 
class Clause (object):
pattern = r'(?!\s+)(.+?(?:\s+-\s*|\s*[–—]\s*|\.{1,3}|[^–—.]+$))'
 
def __init__ (self, text):
self._text = text
self._phrases = []
 
def __str__(self):
return self._text
 
def translate (self, dictionary):
# Find phrases by attempts to translate
words = findall(r'[^\s.]+', self._text)
 
dmsg("words:", words, min_level=2)
 
offset = 0
while offset < len(words):
translation = None
 
for i in range(len(words), offset, -1):
dmsg("words[{0}:{1}] = {2}".format(offset, i, words[offset:i]), min_level=2)
 
phrase = ' '.join(words[offset:i])
 
dmsg("phrase:", phrase, min_level=2)
 
translation = dictionary.translate(phrase)
 
if translation is not None:
dmsg("phrase-translation:", translation, min_level=2)
dmsg("words[{0}:{1}] = [\"{2}\"]".format(offset, i, translation), min_level=2)
 
self._phrases.append(translation)
offset += i - offset
break
 
if translation is None:
dmsg("phrase-translation:", translation, min_level=2)
self._phrases.append(phrase)
offset += 1
 
dmsg("phrases:", self._phrases, min_level=2)
 
class Sentence (object):
pattern = '(?!\s+)(.+?\.{1,3}|.+$)'
 
def __init__ (self, text):
self._text = text
self.find_clauses(text)
 
def __str__(self):
return self._text
 
def find_clauses (self, text):
self._clauses = list(map(
lambda clause_text: Clause(clause_text),
findall(Clause.pattern, text, DOTALL)))
 
def translate (self, dictionary):
for clause in self._clauses:
clause.translate(dictionary)
 
class Paragraph (object):
pattern = r'.+?(?:(?:\r?\n|\r){2,}|$)'
 
def __init__ (self, text):
self._text = text
self.find_sentences(text)
 
def __str__ (self):
return self._text
 
def find_sentences (self, text):
sentences = findall(Sentence.pattern, text, DOTALL)
self._sentences = list(map(
lambda sentence_text: Sentence(sentence_text),
sentences))
 
def translate (self, dictionary):
for sentence in self._sentences:
sentence.translate(dictionary)
 
class Text (object):
def __init__ (self, text):
self._text = text
self.find_paragraphs(text)
 
def __repr__ (self):
return ''.join(map(lambda p: p.__repr__(), self._paragraphs))
 
def __str__ (self):
return self._text
 
def find_paragraphs (self, text):
self._paragraphs = list(map(
lambda paragraph_text: Paragraph(paragraph_text),
findall(Paragraph.pattern, text, DOTALL)))
 
def translate (self, dictionary):
for paragraph in self._paragraphs:
paragraph.translate(dictionary)
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: eazytrans
===================================================================
--- eazytrans (revision 298)
+++ eazytrans (revision 300)
/eazytrans
Property changes:
Added: svn:ignore
## -0,0 +1 ##
+*.pickle