Commit 6a2251a854e50e060627cc83b619b396b17d0ecb

Authored by Bartłomiej Nitoń
1 parent 1c808ba3

Add stats by POS printing to create_TEI_walenty script.

dictionary/management/commands/create_TEI_walenty.py
... ... @@ -7,7 +7,7 @@ import tarfile
7 7 from django.core.management.base import BaseCommand
8 8 from optparse import make_option
9 9  
10   -from dictionary.models import Lemma, Frame_Opinion_Value, \
  10 +from dictionary.models import Lemma, Frame_Opinion_Value, POS, \
11 11 get_statuses
12 12 from dictionary.teixml import createteixml, write_phrase_types_expansions_in_TEI
13 13 from settings import WALENTY_PATH
... ... @@ -126,6 +126,10 @@ class Command(BaseCommand):
126 126 return Lemma.objects.filter(pk__in=all_lemmas_pks)
127 127  
128 128 def print_statistics(self, lemmas):
  129 + self.print_total_statistics(lemmas)
  130 + self.print_statistics_by_pos(lemmas)
  131 +
  132 + def print_total_statistics(self, lemmas):
129 133 count = {'frames': 0,
130 134 'arguments': 0}
131 135 for lemma in lemmas:
... ... @@ -133,6 +137,23 @@ class Command(BaseCommand):
133 137 count['frames'] += frames.count()
134 138 for frame in frames.all():
135 139 count['arguments'] += frame.complements.count()
136   - print (u'Lemmas:\t%d' % lemmas.count())
137   - print (u'Frames:\t%d' % count['frames'])
138   - print (u'Arguments:\t%d' % count['arguments'])
  140 + print (u'Total:')
  141 + print (u'-- Lemmas:\t%d' % lemmas.count())
  142 + print (u'-- Frames:\t%d' % count['frames'])
  143 + print (u'-- Arguments:\t%d' % count['arguments'])
  144 +
  145 + def print_statistics_by_pos(self, lemmas):
  146 + for pos in POS.objects.all():
  147 + pos_lemmas = lemmas.filter(entry_obj__tag=pos)
  148 + if pos_lemmas.exists():
  149 + count = {'frames': 0,
  150 + 'arguments': 0}
  151 + for lemma in pos_lemmas:
  152 + frames = lemma.entry_obj.visible_frames()
  153 + count['frames'] += frames.count()
  154 + for frame in frames.all():
  155 + count['arguments'] += frame.complements.count()
  156 + print (u'%s (%s):' % (pos.name, pos.tag))
  157 + print (u'-- Lemmas:\t%d' % pos_lemmas.count())
  158 + print (u'-- Frames:\t%d' % count['frames'])
  159 + print (u'-- Arguments:\t%d' % count['arguments'])
... ...