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,18 → 54,15 |
|
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 = super().translate(phrase) |
translation = dictionary.get(phrase.lower(), None) |
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: |
96,7 → 93,7 |
cli_help() |
exit(1) |
|
text = ' '.join(argv[1:]) |
text = argv[1] |
|
dictionary = VulcanDictionary(dictionary) |
dictionary.load('vuh-gol-en.dict.zdb.txt', 'vuh') |
149,12 → 146,3 |
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) |