get_stats.py
2.21 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
#-*- coding:utf-8 -*-
import datetime
from collections import Counter
from django.core.management.base import BaseCommand
from dictionary.models import get_checked_statuses, get_ready_statuses
from dictionary.ajax_vocabulary_management import get_stats, write_stats
class Command(BaseCommand):
help = 'Get Walenty statistics.'
def handle(self, **options):
now = datetime.datetime.now().strftime('%Y%m%d')
all_statuses = get_ready_statuses()
verified_statuses = get_checked_statuses()
nouns_stats_dict_all = Counter(get_stats(all_statuses, 'noun'))
write_stats('data/stats_%s_nouns_all.txt' % now, nouns_stats_dict_all)
nouns_stats_dict_verified = Counter(get_stats(verified_statuses, 'noun'))
write_stats('data/stats_%s_nouns_verified.txt' % now, nouns_stats_dict_verified)
adjs_stats_dict_all = Counter(get_stats(all_statuses, 'adj'))
write_stats('data/stats_%s_adjs_all.txt' % now, adjs_stats_dict_all)
adjs_stats_dict_verified = Counter(get_stats(verified_statuses, 'adj'))
write_stats('data/stats_%s_adjs_verified.txt' % now, adjs_stats_dict_verified)
verbs_stats_dict_all = Counter(get_stats(all_statuses, 'verb'))
write_stats('data/stats_%s_verbs_all.txt' % now, verbs_stats_dict_all)
verbs_stats_dict_verified = Counter(get_stats(verified_statuses, 'verb'))
write_stats('data/stats_%s_verbs_verified.txt' % now, verbs_stats_dict_verified)
advs_stats_dict_all = Counter(get_stats(all_statuses, 'adv'))
write_stats('data/stats_%s_advs_all.txt' % now, advs_stats_dict_all)
advs_stats_dict_verified = Counter(get_stats(verified_statuses, 'adv'))
write_stats('data/stats_%s_advs_verified.txt' % now, advs_stats_dict_verified)
all_stats_dict_all = nouns_stats_dict_all + adjs_stats_dict_all + verbs_stats_dict_all + advs_stats_dict_all
all_stats_dict_verified = nouns_stats_dict_verified + adjs_stats_dict_verified + verbs_stats_dict_verified + advs_stats_dict_verified
write_stats('data/stats_%s_all.txt' % now, all_stats_dict_all)
write_stats('data/stats_%s_verified.txt' % now, all_stats_dict_verified)