get_lemmas_stats.py
1.64 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
#-*- coding:utf-8 -*-
import datetime
from django.core.management.base import BaseCommand
from dictionary.models import Lemma
from dictionary.models import get_checked_statuses
STARTDATE = datetime.datetime(2018, 7, 1, 00, 00)
ENDDATE = datetime.datetime(2019, 1, 1, 00, 00)
class Command(BaseCommand):
help = 'Get Walenty lemmas simple statistics.'
def handle(self, **options):
get_lemmas_stats(STARTDATE, ENDDATE, 'noun')
get_lemmas_stats(STARTDATE, ENDDATE, 'verb')
get_lemmas_stats(STARTDATE, ENDDATE, 'adv')
get_lemmas_stats(STARTDATE, ENDDATE, 'adj')
def get_lemmas_stats(start, end, pos):
checked_statuses = get_checked_statuses()
stats = {u'Sprawdzone składniowo': [],
u'Wykonane semantycznie': [],
u'Sprawdzone semantycznie': []}
lemmas = Lemma.objects.filter(old=False,
entry_obj__pos__tag=pos).filter(status__in=checked_statuses).distinct()
for lemma in lemmas.order_by('entry_obj__name').all():
history_from_to = lemma.status_history.filter(date__gte=start, date__lt=end)
if history_from_to.filter(status__type__sym_name='checked').exists():
stats[u'Sprawdzone składniowo'].append(lemma.entry_obj.name)
if history_from_to.filter(status__type__sym_name='ready_s').exists():
stats[u'Wykonane semantycznie'].append(lemma.entry_obj.name)
if history_from_to.filter(status__type__sym_name='checked_s').exists():
stats[u'Sprawdzone semantycznie'].append(lemma.entry_obj.name)
print(pos)
for key in stats:
print(key, len(stats[key]))
print(stats[key])