Allow wildcard searches for terms
Former-commit-id: 36a1031eaa5517afe836b966568b888a49803db9
This commit is contained in:
parent
0c4fff7d3e
commit
80c37a0c85
@ -26,14 +26,14 @@ class Dictionary:
|
|||||||
self.indices = set()
|
self.indices = set()
|
||||||
|
|
||||||
|
|
||||||
def findTerm(self, word):
|
def findTerm(self, word, partial=False):
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
|
|
||||||
if not self.hasIndex('TermIndex'):
|
if not self.hasIndex('TermIndex'):
|
||||||
cursor.execute('CREATE INDEX TermIndex ON Terms(expression, reading)')
|
cursor.execute('CREATE INDEX TermIndex ON Terms(expression, reading)')
|
||||||
self.db.commit()
|
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()
|
return cursor.fetchall()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user