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): ...@@ -1207,12 +1207,17 @@ def get_dictionary(request, unit_id):
Lists words from dictionary for current translation. Lists words from dictionary for current translation.
''' '''
unit = get_object_or_404(Unit, pk = int(unit_id)) unit = get_object_or_404(Unit, pk = int(unit_id))
# split to words words = set()
ana = StandardAnalyzer()
words_std = [token.text for token in ana(unit.get_source_plurals()[0])] # Fetch words from all plurals and from context
# additionally extract stems, to catch things like plurals for text in unit.get_source_plurals() + [unit.context]:
ana = StemmingAnalyzer() # split to words
words_stem = [token.text for token in ana(unit.get_source_plurals()[0])] 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 # join both lists
words = set(words_std).union(words_stem) 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