projects
/
zzz-pokedex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
929cfc5
)
Return correctly-cased foreign names from lookup. #15
author
Eevee
<git@veekun.com>
Sun, 23 Aug 2009 03:49:07 +0000
(20:49 -0700)
committer
Eevee
<git@veekun.com>
Sun, 23 Aug 2009 03:49:07 +0000
(20:49 -0700)
pokedex/lookup.py
patch
|
blob
|
history
diff --git
a/pokedex/lookup.py
b/pokedex/lookup.py
index
0fa91cb
..
16c4e5e
100644
(file)
--- a/
pokedex/lookup.py
+++ b/
pokedex/lookup.py
@@
-81,6
+81,7
@@
def open_index(directory=None, session=None, recreate=False):
table=whoosh.fields.STORED,
row_id=whoosh.fields.ID(stored=True),
language=whoosh.fields.STORED,
table=whoosh.fields.STORED,
row_id=whoosh.fields.ID(stored=True),
language=whoosh.fields.STORED,
+ display_name=whoosh.fields.STORED, # non-lowercased name
)
index = whoosh.index.create_in(directory, schema=schema, indexname='MAIN')
)
index = whoosh.index.create_in(directory, schema=schema, indexname='MAIN')
@@
-102,29
+103,34
@@
def open_index(directory=None, session=None, recreate=False):
for row in q.yield_per(5):
row_key = dict(table=cls.__tablename__, row_id=unicode(row.id))
for row in q.yield_per(5):
row_key = dict(table=cls.__tablename__, row_id=unicode(row.id))
- name = row.name.lower()
- writer.add_document(name=name, **row_key)
- speller_entries.append((name, 1))
+ name = row.name
+ writer.add_document(name=name.lower(),
+ display_name=name,
+ **row_key)
+ speller_entries.append((name.lower(), 1))
# Pokemon also get other languages
for foreign_name in getattr(row, 'foreign_names', []):
# Pokemon also get other languages
for foreign_name in getattr(row, 'foreign_names', []):
- moonspeak = foreign_name.name
.lower()
+ moonspeak = foreign_name.name
if name == moonspeak:
# Don't add the English name again as a different language;
# no point and it makes spell results confusing
continue
if name == moonspeak:
# Don't add the English name again as a different language;
# no point and it makes spell results confusing
continue
- writer.add_document(name=moonspeak,
+ writer.add_document(name=moonspeak
.lower()
,
language=foreign_name.language.name,
language=foreign_name.language.name,
+ display_name=moonspeak,
**row_key)
**row_key)
- speller_entries.append((moonspeak, 3))
+ speller_entries.append((moonspeak
.lower()
, 3))
# Add Roomaji too
if foreign_name.language.name == 'Japanese':
# Add Roomaji too
if foreign_name.language.name == 'Japanese':
- roomaji = romanize(foreign_name.name).lower()
- writer.add_document(name=roomaji, language='Roomaji',
+ roomaji = romanize(foreign_name.name)
+ writer.add_document(name=roomaji.lower(),
+ language='Roomaji',
+ display_name=roomaji,
**row_key)
**row_key)
- speller_entries.append((roomaji, 8))
+ speller_entries.append((roomaji
.lower()
, 8))
writer.commit()
writer.commit()
@@
-248,7
+254,7
@@
def lookup(input, session=None, indices=None, exact_only=False):
cls = indexed_tables[result['table']]
obj = session.query(cls).get(result['row_id'])
objects.append(LookupResult(object=obj,
cls = indexed_tables[result['table']]
obj = session.query(cls).get(result['row_id'])
objects.append(LookupResult(object=obj,
- name=result['name'],
+ name=result['
display_
name'],
language=result['language'],
exact=exact))
language=result['language'],
exact=exact))