Subversion Repositories LCARS

Compare Revisions

Last modification

Ignore whitespace Rev 295 → Rev 296

/trunk/tools/eazytrans/vuh.py
24,7 → 24,7
def cli_help():
print('Usage: {0} TEXT...'.format(basename(argv[0])))
 
def get_sort_dict_alnum_vulcan_key():
def get_sort_dict_alnum_vulcan_key ():
letters = list(map(str.lower, [
" ", 'S', 'T', 'P', 'K', 'R', 'L', 'A', 'Sh', 'O', 'U', 'D',
'V', 'Kh', 'E', 'H', 'G', 'Ch', 'I', 'N', 'Zh', 'M', 'Y', 'F', 'Z',
54,15 → 54,18
 
return cmp_to_key(sort_dict_alnum_vulcan)
 
class VulcanDictionary(Dictionary):
class VulcanDictionary (Dictionary):
def translate (self, phrase, search_prefix=True, search_plural=True):
dictionary = self
 
translation = dictionary.get(phrase.lower(), None)
translation = super().translate(phrase)
if translation is not None:
translation['vuh'] = phrase
return translation
else:
expr_translation = dictionary.translate_expression(phrase)
if expr_translation is not None:
return expr_translation
 
if search_prefix:
# find prefix
for preposition in prepositions:
93,7 → 96,7
cli_help()
exit(1)
 
text = argv[1]
text = ' '.join(argv[1:])
 
dictionary = VulcanDictionary(dictionary)
dictionary.load('vuh-gol-en.dict.zdb.txt', 'vuh')
146,3 → 149,12
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)
# dmsg(dictionary._expressions)