Commit 21fc5b3ec5fce0455d8aad3c92cf34442153e194

Authored by janek37
1 parent 5e7bf181

pomijanie numerów homonimów w eksporcie dla homonimów z różnych części mowy

Showing 1 changed file with 8 additions and 1 deletions
dictionary/export.py
... ... @@ -218,7 +218,10 @@ class LexemeExport(object):
218 218 if UNDERSCORES:
219 219 quals = quals.replace(' ', '_')
220 220 if self.data['homonym_numbers'] and entry in self.homonym_entries:
221   - hn = hn or ''
  221 + if (entry, pos) in self.homonyms_with_numbers:
  222 + assert hn
  223 + else:
  224 + hn = ''
222 225 letter = HomonymNumber.MORFEUSZ_LETTERS_REVERSE.get(
223 226 self.TRANSLATE_NESTED.get(pos, pos))
224 227 assert letter
... ... @@ -336,6 +339,10 @@ where ls.slownik in (%(vocabs)s) and %(antivocabs)s %(x_qual)s %(table_clause)s
336 339 self.homonym_entries = set(
337 340 self.queryset().values('entry').annotate(count=Count('pk'))
338 341 .filter(count__gt=1).values_list('entry', flat=True))
  342 + self.homonyms_with_numbers = set(
  343 + self.queryset().values('entry', 'part_of_speech')
  344 + .annotate(count=Count('pk')).filter(count__gt=1)
  345 + .values_list('entry', 'part_of_speech', flat=True))
339 346 cursor = connection.cursor()
340 347 tts = TableTemplate.objects.filter(
341 348 variant_id=self.data['variant']).prefetch_related(
... ...