if not dictionary.check(t):
try:
- change[t] = dictionary.suggest(t)[0]
+ change_to = dictionary.suggest(t)[0].lower()
+ if change_to != t.lower():
+ change[t] = change_to
except IndexError:
pass
tags = s.hint_tags(prefix, pdcounter=True)
books = s.hint_books(prefix)
- # TODO DODAC TU HINTY
+ def category_name(c):
+ if c.startswith('pd_'):
+ c=c[len('pd_'):]
+ return _(c)
return JSONResponse(
[{'label': t.name,
- 'category': _(t.category),
+ 'category': category_name(t.category),
'id': t.id,
'url': t.get_absolute_url()}
for t in tags] + \
results = None
query = None
- fuzzy = False
+ fuzzy = False #0.8
if 'q' in request.GET:
# tags = request.GET.get('tags', '')
# hint.tags(tag_list)
# if book:
# hint.books(book)
- tags = srch.hint_tags(query, pdcounter=True, prefix=False)
+ tags = srch.hint_tags(query, pdcounter=True, prefix=False, fuzzy=fuzzy)
tags = split_tags(tags)
toks = StringReader(query)
tokens_cache = {}
- fuzzy = 'fuzzy' in request.GET
- if fuzzy:
- fuzzy = 0.7
author_results = srch.search_phrase(toks, 'authors', fuzzy=fuzzy, tokens_cache=tokens_cache)
title_results = srch.search_phrase(toks, 'title', fuzzy=fuzzy, tokens_cache=tokens_cache)
if len(results) == 1:
fragment_hits = filter(lambda h: 'fragment' in h, results[0].hits)
if len(fragment_hits) == 1:
- anchor = fragment_hits[0]['fragment']
- frag = Fragment.objects.get(anchor=anchor)
- return HttpResponseRedirect(frag.get_absolute_url())
+ #anchor = fragment_hits[0]['fragment']
+ #frag = Fragment.objects.get(anchor=anchor)
+ return HttpResponseRedirect(fragment_hits[0]['fragment'].get_absolute_url())
return HttpResponseRedirect(results[0].book.get_absolute_url())
elif len(results) == 0:
form = PublishingSuggestForm(initial={"books": query + ", "})