Commit 17e8db1e380db13d860843d8cb117b740e1b1b6d
1 parent
020c5367
wstępne raporty
Showing
3 changed files
with
72 additions
and
1 deletions
dictionary/reports.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | +from dictionary.models import Lexeme, LexemeAttributeValue, Pattern, \ | |
3 | + CrossReferenceType | |
4 | + | |
5 | +report_functions = [] | |
6 | + | |
7 | +def report_list(fun): | |
8 | + report_functions.append(fun) | |
9 | + return fun | |
10 | + | |
11 | + | |
12 | +@report_list | |
13 | +def derivatives_without_verb(): | |
14 | + derivatives = Lexeme.objects.filter( | |
15 | + part_of_speech__symbol__in=('ger', 'pact', 'ppas', 'appas')) | |
16 | + return { | |
17 | + u'Brak odsyłacza do czasownika': | |
18 | + derivatives.exclude(refs_to__type__symbol__endswith='ver'), | |
19 | + } | |
20 | + | |
21 | + | |
22 | +@report_list | |
23 | +def verbs_without_derivatives(): | |
24 | + proper = list(LexemeAttributeValue.objects.filter( | |
25 | + attribute__name=u'właściwy').exclude(value='Q')) | |
26 | + trans = LexemeAttributeValue.objects.get( | |
27 | + attribute__name=u'przechodniość', value='T') | |
28 | + q_trans = LexemeAttributeValue.objects.get( | |
29 | + attribute__name=u'przechodniość', value='qT') | |
30 | + imperf = list(LexemeAttributeValue.objects.filter( | |
31 | + attribute__name=u'aspekt').exclude(value='dk')) | |
32 | + ppas = CrossReferenceType.objects.get( | |
33 | + symbol='verppas', to_pos__symbol='ppas') | |
34 | + appas = CrossReferenceType.objects.get( | |
35 | + symbol='verppas', to_pos__symbol='appas') | |
36 | + patterns10 = list(Pattern.objects.filter( | |
37 | + type__lexical_class_id='v', endings__base_form_label__symbol='10')) | |
38 | + proper_verbs = Lexeme.objects.filter( | |
39 | + part_of_speech__symbol='v', lexemeattributevalue__in=proper) | |
40 | + # czasownik właściwy przechodni wymaga imiesłowu biernego | |
41 | + proper_trans = proper_verbs.filter(lexemeattributevalue=trans) | |
42 | + no_ppas = proper_trans.exclude(refs_to__type=ppas) | |
43 | + # czasownik właściwy quasi-przechodni wymaga quasi-imiesłowu biernego | |
44 | + proper_qt = proper_verbs.filter(lexemeattributevalue=q_trans) | |
45 | + no_appas = proper_qt.exclude(refs_to__type=appas) | |
46 | + # czasownik właściwy niedokononany wymaga imiesłowu czynnego | |
47 | + proper_imperf = proper_verbs.filter(lexemeattributevalue__in=imperf) | |
48 | + no_pact = proper_imperf.exclude(refs_to__type__symbol='verpact') | |
49 | + # czasownik właściwy z wzorem z zakończeniem 10 wymaga gerundium | |
50 | + proper_10 = proper_verbs.filter(patterns__in=patterns10) | |
51 | + no_ger = proper_10.exclude(refs_to__type__symbol='verger') | |
52 | + return { | |
53 | + u'Brak imiesłowu biernego': no_ppas, | |
54 | + u'Brak quasi-imiesłowu biernego': no_appas, | |
55 | + u'Brak imiesłowu czynnego': no_pact, | |
56 | + u'Brak odsłownika': no_ger, | |
57 | + } | |
0 | 58 | \ No newline at end of file |
... | ... |
dictionary/templates/reports.html
... | ... | @@ -6,4 +6,12 @@ |
6 | 6 | <p> |
7 | 7 | Tu będą różnorodne zestawienia pokazujące stan opracowywanego słownika. |
8 | 8 | </p> |
9 | + {% for header, list in report_lists.iteritems %} | |
10 | + <h3>{{ header }}</h3> | |
11 | + <ul> | |
12 | + {% for l in list %} | |
13 | + <li>{{ l.entry }} {{ l.part_of_speech.symbol }}</li> | |
14 | + {% endfor %} | |
15 | + </ul> | |
16 | + {% endfor %} | |
9 | 17 | {% endblock %} |
... | ... |
dictionary/views.py
... | ... | @@ -10,6 +10,7 @@ from django.http import HttpResponseRedirect, HttpResponse |
10 | 10 | from common.decorators import render |
11 | 11 | from common.util import make_form, GroupDict, json_decode |
12 | 12 | from dictionary.ajax_lexeme_slickgrid import LexemeQuery |
13 | +from dictionary.reports import report_functions | |
13 | 14 | from paginer import PaginationList |
14 | 15 | from paginer.decorators import paginated |
15 | 16 | from dictionary.forms import AddClassificationForm, ExclusionClassForm, \ |
... | ... | @@ -238,7 +239,12 @@ def tasks(request): |
238 | 239 | @login_required |
239 | 240 | @render() |
240 | 241 | def reports(request): |
241 | - return {} | |
242 | + report_lists = {} | |
243 | + for report_fun in report_functions: | |
244 | + report_lists.update(report_fun()) | |
245 | + return { | |
246 | + 'report_lists': report_lists | |
247 | + } | |
242 | 248 | |
243 | 249 | |
244 | 250 | @login_required |
... | ... |