#-*- coding:utf-8 -*-

from django.core.management.base import BaseCommand

from dictionary.models import Lemma

class Command(BaseCommand):
    args = 'none'
    help = ""

    def handle(self, **options):
        count_semantic_stats()
        
def count_semantic_stats():
    count = {'frames': 0,
             'arguments': 0}
    lemmas = Lemma.objects.filter(old=False).order_by('entry_obj__name')
    for lemma in lemmas:
        if lemma.semantics_ready():
            print lemma
            frames = lemma.entry_obj.actual_frames()
            count['frames'] += frames.count()
            for frame in frames.all():
                count['arguments'] += frame.complements.count()
    print u'Frames:\t%d' % count['frames']
    print u'Arguments:\t%d' % count['arguments']
