wrong_derivatives.py
2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from django.db import transaction
from common.util import uniprint, no_history
from dictionary.auto_derivatives import ppas_data, pact_data, create_derivative
from dictionary.models import Pattern, Lexeme, LexemeAttributeValue, Ending, \
LexemeForm
class Command(BaseCommand):
help = "Convert derivatives so they don't use verb patterns"
def handle(self, *args, **options):
wrong_derivatives()
INTRANS = LexemeAttributeValue.objects.get(
attribute__name=u'przechodniość', value='iT')
DK = LexemeAttributeValue.objects.get(attribute__name=u'aspekt', value='dk')
NDK = LexemeAttributeValue.objects.get(attribute__name=u'aspekt', value='ndk')
def wrong_derivatives():
transaction.commit_unless_managed()
transaction.enter_transaction_management()
transaction.managed()
no_history()
verbs = Lexeme.objects.filter(part_of_speech='v', owner_vocabulary='SGJP')
intrans = verbs.filter(lexemeattributevalue=INTRANS)
dk = verbs.filter(lexemeattributevalue=DK)
ndk = verbs.filter(lexemeattributevalue=NDK)
wrong_participles = set()
for l in intrans:
for data in ppas_data(l):
der = create_derivative(
l, data['pos'], data['entry'], data['index'], pl=data['pl'])
wrong_participles |= der.all_forms()
for l in dk:
for data in pact_data(l):
der = create_derivative(
l, data['pos'], data['entry'], data['index'])
wrong_participles |= der.all_forms()
lips = list(l.lexemeinflectionpattern_set.all())
for lip in lips:
pattern = lip.pattern
endings3 = Ending.objects.filter(
pattern=pattern, base_form_label__symbol='3')
for ending in endings3:
wrong_participles.add(lip.root + ending.string + u'c')
for l in ndk:
lips = list(l.lexemeinflectionpattern_set.all())
for lip in lips:
pattern = lip.pattern
endings6p = Ending.objects.filter(
pattern=pattern, base_form_label__symbol="6'")
for ending in endings6p:
wrong_participles.add(lip.root + ending.string + u'szy')
wrong_participles -= set(LexemeForm.objects.values_list('form', flat=True))
for p in sorted(wrong_participles):
uniprint(p)
transaction.rollback()
transaction.leave_transaction_management()