Commit 9e395812b4fbcd310e0af725a07d30bd8b49989d

Authored by janek37
1 parent a74db45d

tymczasowa poprawka kopiowania aspektu

dictionary/management/commands/import_data.py
... ... @@ -389,6 +389,24 @@ class ImportData(object):
389 389 from_lexeme_id=row['nrod'], to_lexeme_id=row['nrdo'],
390 390 type=cr_type)
391 391  
  392 + def copy_aspects(self, lexeme_attrs):
  393 + aspect_vals = LexemeAttributeValue.objects.filter(attribute__name='aspekt')
  394 + aspect_avs = []
  395 + control_set = set()
  396 + # TODO zrobić zapytanie które weźmie gotowe dane z sqlite
  397 + for lexeme_av in lexeme_attrs:
  398 + if lexeme_av.attribute_value in aspect_vals:
  399 + crs = CrossReference.objects.filter(
  400 + from_lexeme__id=lexeme_av.lexeme_id,
  401 + type__symbol__in=('verger', 'verppas', 'verpact'))
  402 + for cr in crs:
  403 + l = cr.to_lexeme
  404 + av = lexeme_av.attribute_value
  405 + if (l, av) not in control_set:
  406 + aspect_avs.append(LexemeAV(lexeme=l, attribute_value=av))
  407 + control_set.add((l, av))
  408 + bulk_create(LexemeAV, aspect_avs)
  409 +
392 410 def import_pattern_types(self):
393 411 self.cache_lc_pos()
394 412 result = self.sqlite_cursor.execute(
... ... @@ -564,19 +582,6 @@ class ImportData(object):
564 582 else:
565 583 raise Exception('Brak szablonu dla nagłówka: %s', dict(row))
566 584  
567   - def copy_aspects(self, lexeme_attrs):
568   - aspect_vals = LexemeAttributeValue.objects.filter(attribute__name='aspekt')
569   - aspect_avs = []
570   - for lexeme_av in lexeme_attrs:
571   - if lexeme_av.attribute_value in aspect_vals:
572   - crs = CrossReference.objects.filter(
573   - from_lexeme__id=lexeme_av.lexeme_id,
574   - type__symbol__in=('verger', 'verppas', 'verpact'))
575   - for cr in crs:
576   - aspect_avs.append(LexemeAV(
577   - lexeme=cr.to_lexeme, attribute_value=lexeme_av.attribute_value))
578   - bulk_create(LexemeAV, aspect_avs)
579   -
580 585 def delete_and_import(self):
581 586 models = (
582 587 TableCell,
... ...