diff --git a/dictionary/management/commands/create_TEI_walenty.py b/dictionary/management/commands/create_TEI_walenty.py index ce766a4..2a73eac 100644 --- a/dictionary/management/commands/create_TEI_walenty.py +++ b/dictionary/management/commands/create_TEI_walenty.py @@ -7,7 +7,7 @@ import tarfile from django.core.management.base import BaseCommand from optparse import make_option -from dictionary.models import Lemma, Frame_Opinion_Value, \ +from dictionary.models import Lemma, Frame_Opinion_Value, POS, \ get_statuses from dictionary.teixml import createteixml, write_phrase_types_expansions_in_TEI from settings import WALENTY_PATH @@ -126,6 +126,10 @@ class Command(BaseCommand): return Lemma.objects.filter(pk__in=all_lemmas_pks) def print_statistics(self, lemmas): + self.print_total_statistics(lemmas) + self.print_statistics_by_pos(lemmas) + + def print_total_statistics(self, lemmas): count = {'frames': 0, 'arguments': 0} for lemma in lemmas: @@ -133,6 +137,23 @@ class Command(BaseCommand): count['frames'] += frames.count() for frame in frames.all(): count['arguments'] += frame.complements.count() - print (u'Lemmas:\t%d' % lemmas.count()) - print (u'Frames:\t%d' % count['frames']) - print (u'Arguments:\t%d' % count['arguments']) + print (u'Total:') + print (u'-- Lemmas:\t%d' % lemmas.count()) + print (u'-- Frames:\t%d' % count['frames']) + print (u'-- Arguments:\t%d' % count['arguments']) + + def print_statistics_by_pos(self, lemmas): + for pos in POS.objects.all(): + pos_lemmas = lemmas.filter(entry_obj__tag=pos) + if pos_lemmas.exists(): + count = {'frames': 0, + 'arguments': 0} + for lemma in pos_lemmas: + frames = lemma.entry_obj.visible_frames() + count['frames'] += frames.count() + for frame in frames.all(): + count['arguments'] += frame.complements.count() + print (u'%s (%s):' % (pos.name, pos.tag)) + print (u'-- Lemmas:\t%d' % pos_lemmas.count()) + print (u'-- Frames:\t%d' % count['frames']) + print (u'-- Arguments:\t%d' % count['arguments'])