From 80c37a0c85535c7a98997385a3535ed2fb6e2452 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 8 Nov 2013 13:02:55 -0800 Subject: [PATCH] Allow wildcard searches for terms Former-commit-id: 36a1031eaa5517afe836b966568b888a49803db9 --- yomi_base/japanese2/dictionary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yomi_base/japanese2/dictionary.py b/yomi_base/japanese2/dictionary.py index cf3c22c..afa80e6 100644 --- a/yomi_base/japanese2/dictionary.py +++ b/yomi_base/japanese2/dictionary.py @@ -26,14 +26,14 @@ class Dictionary: self.indices = set() - def findTerm(self, word): + def findTerm(self, word, partial=False): cursor = self.db.cursor() if not self.hasIndex('TermIndex'): cursor.execute('CREATE INDEX TermIndex ON Terms(expression, reading)') self.db.commit() - cursor.execute('SELECT * FROM Terms WHERE expression=? OR reading=?', (word, word)) + cursor.execute('SELECT * FROM Terms WHERE expression {0} ? OR reading=?'.format('LIKE' if partial else '='), (word, word)) return cursor.fetchall()