1

Cleaning up some stuff in dictionary and translator

Former-commit-id: ca940dc4fbf1ca80e889a3dd1cf5e1c2af98ba8a
This commit is contained in:
Alex Yatskov 2013-11-12 19:56:52 -08:00
parent efc9310da4
commit 30badd7967
2 changed files with 4 additions and 2 deletions

View File

@ -46,6 +46,7 @@ class Dictionary:
def findCharacter(self, character):
assert len(character) == 1
self.requireIndex('Kanji', 'character')
cursor = self.db.cursor()
@ -65,12 +66,12 @@ class Dictionary:
def findCharacterVisually(self, characters):
radicals = dict()
for character in characters:
for radical in self.findRadicalsByCharacter(character):
for radical in self.findRadicalsByCharacter(character) or list():
radicals[radical] = radicals.get(radical, 0) + 1
characters = dict()
for radical, count in radicals.items():
for character in self.findCharactersByRadical(radical):
for character in self.findCharactersByRadical(radical) or list():
characters[character] = characters.get(character, 0) + count
results = list()

View File

@ -51,6 +51,7 @@ class Translator:
def findCharacter(self, text):
assert len(text) == 1
return self.dictionary.findCharacter(text)