batterseapower / pinyin-toolkit

A plugin for the Anki Spaced Repetition System (http://ichi2.net/anki/)
http://batterseapower.github.com/pinyin-toolkit/
39 stars 14 forks source link

Add limit on text-masker to prevent self-return of masking character #55

Closed Nick3C closed 15 years ago

Nick3C commented 15 years ago

google sometimes returns only the query (if it is feeling particularly useless or the words has been censored [such as swearing]). Need to add a check to see if text is the same otherwise just the masking character and the google translate notice are returned (which is ugly).

batterseapower commented 15 years ago

Done in my branch.

Nick3C commented 15 years ago

Seems to still be some problems here. Try: 偏题

File "C:\Documents and Settings\Nick\Application Data.anki\plugins\pinyin\anki\hooks.py", line 37, in pinyin.utils.suppressexceptions(lambda: self.updater.updatefact(factproxy, field.value)) File "C:\Documents and Settings\Nick\Application Data.anki\plugins\pinyin\updater.py", line 170, in updatefact meaning = self.generatemeanings(expression, dictmeanings) File "C:\Documents and Settings\Nick\Application Data.anki\plugins\pinyin\updater.py", line 92, in generatemeanings dictmeanings = [transformations.maskhanzi(expression, self.config.hanzimaskingcharacter, dictmeaning) for dictmeaning in dictmeanings] File "C:\Documents and Settings\Nick\Application Data.anki\plugins\pinyin\transformations.py", line 157, in maskhanzi return token.accept(MaskHanziVisitor(expression, maskingcharacter)) AttributeError: 'unicode' object has no attribute 'accept'

batterseapower commented 15 years ago

Hmm, I can't reproduce that error, but I may have inadvertently fixed it in my most recent refactoring (that code doesn't exist any longer).

Nick3C commented 15 years ago

ah, neat :)