本文整理汇总了Python中plover.steno_dictionary.StenoDictionaryCollection.casereverse_lookup方法的典型用法代码示例。如果您正苦于以下问题:Python StenoDictionaryCollection.casereverse_lookup方法的具体用法?Python StenoDictionaryCollection.casereverse_lookup怎么用?Python StenoDictionaryCollection.casereverse_lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plover.steno_dictionary.StenoDictionaryCollection
的用法示例。
在下文中一共展示了StenoDictionaryCollection.casereverse_lookup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dictionary_enabled
# 需要导入模块: from plover.steno_dictionary import StenoDictionaryCollection [as 别名]
# 或者: from plover.steno_dictionary.StenoDictionaryCollection import casereverse_lookup [as 别名]
def test_dictionary_enabled(self):
dc = StenoDictionaryCollection()
d1 = StenoDictionary()
d1.path = 'd1'
d1[('TEFT',)] = 'test1'
d1[('TEFGT',)] = 'Testing'
d2 = StenoDictionary()
d2[('TEFT',)] = 'test2'
d2[('TEFT','-G')] = 'Testing'
d2.path = 'd2'
dc.set_dicts([d2, d1])
self.assertEqual(dc.lookup(('TEFT',)), 'test2')
self.assertEqual(dc.raw_lookup(('TEFT',)), 'test2')
self.assertEqual(dc.casereverse_lookup('testing'), ['Testing'])
assertCountEqual(self, dc.reverse_lookup('Testing'), [('TEFGT',), ('TEFT', '-G')])
d2.enabled = False
self.assertEqual(dc.lookup(('TEFT',)), 'test1')
self.assertEqual(dc.raw_lookup(('TEFT',)), 'test1')
self.assertEqual(dc.casereverse_lookup('testing'), ['Testing'])
assertCountEqual(self, dc.reverse_lookup('Testing'), [('TEFGT',)])
d1.enabled = False
self.assertEqual(dc.lookup(('TEST',)), None)
self.assertEqual(dc.raw_lookup(('TEFT',)), None)
self.assertEqual(dc.casereverse_lookup('testing'), None)
assertCountEqual(self, dc.reverse_lookup('Testing'), [])
示例2: test_dictionary_enabled
# 需要导入模块: from plover.steno_dictionary import StenoDictionaryCollection [as 别名]
# 或者: from plover.steno_dictionary.StenoDictionaryCollection import casereverse_lookup [as 别名]
def test_dictionary_enabled():
dc = StenoDictionaryCollection()
d1 = StenoDictionary()
d1.path = 'd1'
d1[('TEFT',)] = 'test1'
d1[('TEFGT',)] = 'Testing'
d2 = StenoDictionary()
d2[('TEFT',)] = 'test2'
d2[('TEFT', '-G')] = 'Testing'
d2.path = 'd2'
dc.set_dicts([d2, d1])
assert dc.lookup(('TEFT',)) == 'test2'
assert dc.raw_lookup(('TEFT',)) == 'test2'
assert dc.casereverse_lookup('testing') == ['Testing']
assert dc.reverse_lookup('Testing') == [('TEFT', '-G'), ('TEFGT',)]
d2.enabled = False
assert dc.lookup(('TEFT',)) == 'test1'
assert dc.raw_lookup(('TEFT',)) == 'test1'
assert dc.casereverse_lookup('testing') == ['Testing']
assert dc.reverse_lookup('Testing') == [('TEFGT',)]
d1.enabled = False
assert dc.lookup(('TEST',)) is None
assert dc.raw_lookup(('TEFT',)) is None
assert dc.casereverse_lookup('testing') is None
assert dc.reverse_lookup('Testing') == []
示例3: StenoEngine
# 需要导入模块: from plover.steno_dictionary import StenoDictionaryCollection [as 别名]
# 或者: from plover.steno_dictionary.StenoDictionaryCollection import casereverse_lookup [as 别名]
#.........这里部分代码省略.........
# We need to go through the queue, even when already called
# from the engine thread so _quit's return code does break
# the thread out of its main loop.
self._queue.put((self._quit, (code,), {}))
def restart(self):
self.quit(-1)
def join(self):
return self.code
@with_lock
def machine_specific_options(self, machine_type):
return self._config.get_machine_specific_options(machine_type)
@with_lock
def system_keymap(self, machine_type, system_name):
return self._config.get_system_keymap(machine_type, system_name)
@with_lock
def lookup(self, translation):
return self._dictionaries.lookup(translation)
@with_lock
def raw_lookup(self, translation):
return self._dictionaries.raw_lookup(translation)
@with_lock
def reverse_lookup(self, translation):
matches = self._dictionaries.reverse_lookup(translation)
return [] if matches is None else matches
@with_lock
def casereverse_lookup(self, translation):
matches = self._dictionaries.casereverse_lookup(translation)
return set() if matches is None else matches
@with_lock
def add_dictionary_filter(self, dictionary_filter):
self._dictionaries.add_filter(dictionary_filter)
@with_lock
def remove_dictionary_filter(self, dictionary_filter):
self._dictionaries.remove_filter(dictionary_filter)
@with_lock
def get_suggestions(self, translation):
return Suggestions(self._dictionaries).find(translation)
@property
@with_lock
def translator_state(self):
return self._translator.get_state()
@translator_state.setter
@with_lock
def translator_state(self, state):
self._translator.set_state(state)
@with_lock
def clear_translator_state(self, undo=False):
if undo:
state = self._translator.get_state()
self._formatter.format(state.translations, (), None)
self._translator.clear_state()