Commit 27a6168ef507d1ffd51a38d02d6eac486c1535a3

Authored by janek37
1 parent d8cc7471

kopiowanie aspektów do derywatów

dictionary/management/commands/import_data.py
... ... @@ -12,8 +12,8 @@ DEFAULT_DATABASE = 'data/sgjp.db'
12 12  
13 13 MINI_MODE = True # do debugowania
14 14 MINI_LEXEME_COUNT = 5000
15   -#MINI_LEXEME_QUERY = "SELECT %s FROM leksemy WHERE pos IN ('v', 'ger', 'pact') LIMIT ?"
16   -MINI_LEXEME_QUERY = "SELECT %s FROM leksemy l WHERE EXISTS (SELECT * FROM odmieniasie WHERE nr = l.nr AND charfl = 'm1') LIMIT ?"
  15 +MINI_LEXEME_QUERY = "SELECT %s FROM leksemy WHERE pos IN ('v', 'ger', 'pact', 'ppas') ORDER BY haslo LIMIT ?"
  16 +#MINI_LEXEME_QUERY = "SELECT %s FROM leksemy l WHERE EXISTS (SELECT * FROM odmieniasie WHERE nr = l.nr AND charfl = 'm1') LIMIT ?"
17 17  
18 18 SQL_MODE = True
19 19  
... ... @@ -34,7 +34,7 @@ ATTRS = {
34 34 ('przechodniosc', lambda x: x),
35 35 ),
36 36 u'aspekt': (
37   - (('v', 'pred'), None),
  37 + (('v', 'pred', 'ger', 'pact', 'ppas'), None),
38 38 ('dk', 'ndk', 'ndk/dk', 'dk/ndk', 'ndk/(dk)', 'dk/(ndk)'),
39 39 ('aspekt', lambda x: x),
40 40 ),
... ... @@ -590,7 +590,8 @@ class ImportData(object):
590 590 print 'attributes...'
591 591 for lexeme_id, attr_val in lexeme_attrs:
592 592 attr_val.lexemes.add(lexeme_id)
593   - import_lexemes()
  593 + return lexeme_attrs
  594 + lexeme_attrs = import_lexemes()
594 595 def import_lips():
595 596 print 'importing lexeme inflection patterns...'
596 597 lips, lip_quals = self.new_lexeme_inflection_patterns()
... ... @@ -608,6 +609,15 @@ class ImportData(object):
608 609 self.new_cross_reference_types())
609 610 print 'importing cross-references...'
610 611 bulk_create(CrossReference, self.new_cross_references())
  612 + print 'copying aspect values to derived lexemes...'
  613 + aspect_vals = LexemeAttributeValue.objects.filter(attribute__name='aspekt')
  614 + for lexeme_id, attr_val in lexeme_attrs:
  615 + if attr_val in aspect_vals:
  616 + crs = CrossReference.objects.filter(
  617 + from_lexeme__id=lexeme_id,
  618 + type__symbol__in=('verger', 'verppas', 'verpact'))
  619 + for cr in crs:
  620 + attr_val.lexemes.add(cr.to_lexeme) #add
611 621 print 'importing variants...'
612 622 bulk_create(Variant, self.new_variants())
613 623 print 'importing table templates...'
... ...