From 46c99d7efb7cc6124994430f58de00d5bdbde19a Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 17 Nov 2013 20:21:57 -0800 Subject: [PATCH] Improvements to text scanning and deinflection display Former-commit-id: 94bfd5c174c2f68dfb85b2040a272e4523f9e799 --- yomi_base/reader.py | 5 +++-- yomi_base/reader_util.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yomi_base/reader.py b/yomi_base/reader.py index 1470ba9..52db538 100644 --- a/yomi_base/reader.py +++ b/yomi_base/reader.py @@ -20,6 +20,7 @@ from PyQt4 import QtGui, QtCore import about import constants import gen.reader_ui +import japanese.util import os import preferences import reader_util @@ -424,7 +425,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader): contentSample = content[samplePosStart:samplePosEnd] contentSampleFlat = contentSample.replace(u'\n', unicode()) - if len(contentSampleFlat) == 0: + if len(contentSampleFlat) == 0 or not japanese.util.isJapanese(contentSampleFlat[0]): cursor.clearSelection() self.textContent.setTextCursor(cursor) return @@ -451,7 +452,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader): if lengthMatched <= 0: break lengthSelect += 1 - if c not in [u'\n', u' ', u' ']: + if c != u'\n': lengthMatched -= 1 cursor.setPosition(samplePosStart, QtGui.QTextCursor.MoveAnchor) diff --git a/yomi_base/reader_util.py b/yomi_base/reader_util.py index 1266f68..b341c72 100644 --- a/yomi_base/reader_util.py +++ b/yomi_base/reader_util.py @@ -168,8 +168,8 @@ def buildVocabDef(definition, index, query): rules = unicode() if len(definition['rules']) > 0: - rules = ' :: '.join(definition['rules']) - rules = '{0}
'.format(rules) + rules = ' < '.join(definition['rules']) + rules = '({0})
'.format(rules) links = ''.format(index) if query is not None: