Commit 06934dd0 authored by Michal Čihař's avatar Michal Čihař

Use context for dictionary lookup as well

parent 3a62d4ac
......@@ -1207,12 +1207,17 @@ def get_dictionary(request, unit_id):
Lists words from dictionary for current translation.
'''
unit = get_object_or_404(Unit, pk = int(unit_id))
# split to words
ana = StandardAnalyzer()
words_std = [token.text for token in ana(unit.get_source_plurals()[0])]
# additionally extract stems, to catch things like plurals
ana = StemmingAnalyzer()
words_stem = [token.text for token in ana(unit.get_source_plurals()[0])]
words = set()
# Fetch words from all plurals and from context
for text in unit.get_source_plurals() + [unit.context]:
# split to words
ana = StandardAnalyzer()
words.union([token.text for token in ana(unit.get_source_plurals()[0])])
# additionally extract stems, to catch things like plurals
ana = StemmingAnalyzer()
words.union([token.text for token in ana(unit.get_source_plurals()[0])])
# join both lists
words = set(words_std).union(words_stem)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment