55,24 → 55,14 |
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: |
""" |
dictionary = self |
|
translation = super().translate(phrase) |
if translation is not None: |
return translation |
else: |
expr_translation = self.translate_expression(phrase) |
expr_translation = dictionary.translate_expression(phrase) |
if expr_translation is not None: |
return expr_translation |
|
100,17 → 90,6 |
|
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) |
178,5 → 157,4 |
else word, |
words)), |
min_level=2) |
# for key, value in dictionary._expressions.items(): |
# dmsg(key, value, min_level=3) |
# dmsg(dictionary._expressions) |