diff --git a/yomi_base/japanese/translate.py b/yomi_base/japanese/translate.py index 0e9c33d..db38c98 100644 --- a/yomi_base/japanese/translate.py +++ b/yomi_base/japanese/translate.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -import util +import re class Translator: @@ -27,7 +27,9 @@ class Translator: def findTerm(self, text, wildcards=False): - text = util.sanitize(text, wildcards=wildcards) + if wildcards: + text = re.sub(u'[\**]', u'%', text) + text = re.sub(u'[\??]', u'_', text) groups = {} for i in xrange(len(text), 0, -1): @@ -60,8 +62,6 @@ class Translator: def findKanji(self, text): - text = util.sanitize(text, kana=False) - processed = {} results = [] for c in text: diff --git a/yomi_base/japanese/util.py b/yomi_base/japanese/util.py deleted file mode 100644 index 9d692ff..0000000 --- a/yomi_base/japanese/util.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2013 Alex Yatskov -# This module is based on Rikaichan code written by Jonathan Zarate -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import re - - -def isHiragana(c): - return 0x3040 <= ord(c) < 0x30a0 - - -def isKatakana(c): - return 0x30a0 <= ord(c) < 0x3100 - - -def isKana(c): - return isHiragana(c) or isKatakana(c) - - -def isKanji(c): - return 0x4e00 <= ord(c) < 0x9fb0 or 0x3400 <= ord(c) < 0x4dc0 - - -def isJapanese(c): - return isKana(c) or isKanji(c) or c == u'々' - - -def sanitize(text, kana=True, wildcards=False): - if kana: - checker = isJapanese - else: - checker = isKanji - - if wildcards: - text = re.sub(u'[\**]', u'%', text) - text = re.sub(u'[\??]', u'_', text) - overrides = [u'%', u'_'] - else: - overrides = [] - - result = u'' - for c in text: - if checker(c) or c in overrides: - result += c - - return result diff --git a/yomi_base/reader.py b/yomi_base/reader.py index d957166..b2d5a08 100644 --- a/yomi_base/reader.py +++ b/yomi_base/reader.py @@ -497,7 +497,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader): cursor = self.textContent.textCursor() - if len(contentSampleFlat) == 0 or not japanese.util.isJapanese(contentSampleFlat[0]): + if len(contentSampleFlat) == 0: cursor.clearSelection() self.textContent.setTextCursor(cursor) return