Commit e0dd37a766f755cf0ba7d916e516bb10dfca0aad
1 parent
54f44ab8
nowa zwrotność w WSJP i schowana z widoku
Showing
4 changed files
with
37 additions
and
18 deletions
dictionary/forms.py
... | ... | @@ -113,7 +113,6 @@ class LexemeEditForm(ModelForm): |
113 | 113 | fields = ( |
114 | 114 | 'part_of_speech', |
115 | 115 | 'entry', |
116 | - 'entry_suffix', | |
117 | 116 | 'pronunciation', |
118 | 117 | 'status', |
119 | 118 | 'gloss', |
... | ... | @@ -122,7 +121,6 @@ class LexemeEditForm(ModelForm): |
122 | 121 | ) |
123 | 122 | widgets = { |
124 | 123 | 'comment': Textarea(attrs={'cols': 40, 'rows': 5}), |
125 | - 'entry_suffix': TextInput(attrs={'size': 5}), | |
126 | 124 | 'gloss': TextInput(attrs={'size': 40}), |
127 | 125 | 'note': TextInput(attrs={'size': 40}), |
128 | 126 | 'pronunciation': TextInput(attrs={'size': 40}), |
... | ... |
dictionary/models.py
... | ... | @@ -319,6 +319,7 @@ class Lexeme(Model): |
319 | 319 | |
320 | 320 | entry = CharField(max_length=64, db_column='haslo', db_index=True, |
321 | 321 | verbose_name=u'hasło', blank=True) # dla nowo utworzonych |
322 | + # pozostałość historyczna: | |
322 | 323 | entry_suffix = CharField(blank=True, max_length=16, db_column='haslosuf', |
323 | 324 | verbose_name=u'sufiks hasła') |
324 | 325 | gloss = TextField(blank=True, db_column='glosa', verbose_name=u'glosa') |
... | ... |
dictionary/templates/lexeme_edit_form.html
1 | 1 | <form action="" method="post" id="lexeme-edit-form"> |
2 | 2 | {% for field in form %} |
3 | - {% if field.name != 'comment' and field.name != 'vocabularies' and field.name != 'qualifiers' and field.name != 'entry_suffix' and field.name != 'new_owner' %} | |
3 | + {% if field.name != 'comment' and field.name != 'vocabularies' and field.name != 'qualifiers' and field.name != 'new_owner' %} | |
4 | 4 | <p class="main-field"> |
5 | 5 | {{ field.label_tag }} {{ field.as_widget }} |
6 | - {% if field.name == 'entry' %} | |
7 | - {{ form.entry_suffix.as_widget }} | |
8 | - {% endif %} | |
9 | 6 | {% if field.name == 'part_of_speech' %} |
10 | 7 | <span id="homonym-count"></span> |
11 | 8 | {% endif %} |
... | ... |
dictionary/wsjp.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from django.db import connection |
3 | +from dictionary.models import LexemeAttributeValue | |
4 | + | |
3 | 5 | |
4 | 6 | def make_data(entries): |
5 | 7 | entry_placeholders = ', '.join('%s' for entry in entries) |
8 | + refls = dict(LexemeAttributeValue.objects.filter( | |
9 | + attribute__name=u'zwrotność').values_list('pk', 'value')) | |
10 | + refl_ids = ', '.join(str(pk) for pk in refls) | |
11 | + refls_rev = dict(LexemeAttributeValue.objects.filter( | |
12 | + attribute__name=u'zwrotność').values_list('value', 'pk')) | |
13 | + nonrefl = [refls_rev[v] for v in (u'—', u'(się)', u'(sobie)')] | |
14 | + nonrefl_ids = ', '.join(str(pk) for pk in nonrefl) | |
15 | + empty_refl = refls_rev[u'—'] | |
6 | 16 | base_query = ''' |
7 | 17 | select distinct pref||rdzen||zak||suf slowo, %(haslo_tab)s, hom, |
8 | 18 | l.pos, |
... | ... | @@ -10,6 +20,8 @@ def make_data(entries): |
10 | 20 | as rodzaj, podparad, row, col, rowspan, colspan, kskl |
11 | 21 | from |
12 | 22 | leksemy l |
23 | + left outer join dictionary_lexemeattributevalue_lexemes refl | |
24 | + on (l.id = refl.lexeme_id and refl.lexemeattributevalue_id in (%(refl)s)) | |
13 | 25 | join odmieniasie o on (l.id = o.l_id) |
14 | 26 | join charfle ch on (o.charfl = ch.id) |
15 | 27 | join wzory on (o.w_id = wzory.id) |
... | ... | @@ -28,6 +40,8 @@ def make_data(entries): |
28 | 40 | join odsylacze ods on l.id = l_id_od |
29 | 41 | join typyodsylaczy tods on ods.typods_id = tods.id |
30 | 42 | join leksemy g on l_id_do = g.id |
43 | + left outer join dictionary_lexemeattributevalue_lexemes refl | |
44 | + on (g.id = refl.lexeme_id and refl.lexemeattributevalue_id in (%(refl)s)) | |
31 | 45 | join odmieniasie o on l.id = o.l_id |
32 | 46 | join charfle ch on (o.charfl = ch.id) |
33 | 47 | join wzory on (o.w_id = wzory.id) |
... | ... | @@ -43,9 +57,11 @@ def make_data(entries): |
43 | 57 | 'haslo': 'haslo', |
44 | 58 | 'entry_placeholders': entry_placeholders, |
45 | 59 | 'leks_clause': '''l.pos not in ('skrl','skrw') and |
46 | - (l.pos != 'v' or haslosuf = '' or haslosuf like %s)''', | |
60 | + (l.pos != 'v' or refl.lexemeattributevalue_id in (%s))''' | |
61 | + % nonrefl_ids, | |
62 | + 'refl': refl_ids, | |
47 | 63 | }, |
48 | - entries + ['%(%', '1'] | |
64 | + entries + ['1'] | |
49 | 65 | ), |
50 | 66 | # czasowniki sięiczne: |
51 | 67 | ( |
... | ... | @@ -53,9 +69,10 @@ def make_data(entries): |
53 | 69 | 'haslo_tab': u"haslo||' się'", |
54 | 70 | 'haslo': 'haslo', |
55 | 71 | 'entry_placeholders': entry_placeholders, |
56 | - 'leks_clause': '''(l.pos='v' and haslosuf <> '')''', | |
72 | + 'leks_clause': '''(l.pos='v' and refl.lexemeattributevalue_id <> %s)''', | |
73 | + 'refl': refl_ids, | |
57 | 74 | }, |
58 | - entries + ['s'] | |
75 | + entries + [empty_refl, 's'] | |
59 | 76 | ), |
60 | 77 | # czasowniki zanegowane: |
61 | 78 | ( |
... | ... | @@ -63,9 +80,11 @@ def make_data(entries): |
63 | 80 | 'haslo_tab': "'nie '||haslo", |
64 | 81 | 'haslo': "'nie '||haslo", |
65 | 82 | 'entry_placeholders': entry_placeholders, |
66 | - 'leks_clause': '''l.pos='v' and (haslosuf = '' or haslosuf like %s)''', | |
83 | + 'leks_clause': '''l.pos='v' and refl.lexemeattributevalue_id in (%s)''' | |
84 | + % nonrefl_ids, | |
85 | + 'refl': refl_ids, | |
67 | 86 | }, |
68 | - entries + ['%(%', 'n'] | |
87 | + entries + ['n'] | |
69 | 88 | ), |
70 | 89 | # czasowniki sięiczne zanegowane: |
71 | 90 | ( |
... | ... | @@ -73,9 +92,10 @@ def make_data(entries): |
73 | 92 | 'haslo_tab': u"'nie '||haslo||' się'", |
74 | 93 | 'haslo': "'nie '||haslo", |
75 | 94 | 'entry_placeholders': entry_placeholders, |
76 | - 'leks_clause': '''(l.pos='v' and haslosuf <> '')''', | |
95 | + 'leks_clause': '''(l.pos='v' and refl.lexemeattributevalue_id <> %s)''', | |
96 | + 'refl': refl_ids, | |
77 | 97 | }, |
78 | - entries + ['ns'] | |
98 | + entries + [empty_refl, 'ns'] | |
79 | 99 | ), |
80 | 100 | # wymagające gniazdowania: adjcom, advcom i ppas |
81 | 101 | ( |
... | ... | @@ -84,9 +104,11 @@ def make_data(entries): |
84 | 104 | 'entry_placeholders': entry_placeholders, |
85 | 105 | 'main_clause': '''typods in ('comadj','comadv','ppasver') and |
86 | 106 | l.pos in ('adjcom','advcom','ppas') and |
87 | - (l.pos != 'ppas' or g.haslosuf = '' or g.haslosuf like %s)''' | |
107 | + (l.pos != 'ppas' or refl.lexemeattributevalue_id in (%s))''' | |
108 | + % nonrefl_ids, | |
109 | + 'refl': refl_ids, | |
88 | 110 | }, |
89 | - entries + ['%(%'] | |
111 | + entries | |
90 | 112 | ), |
91 | 113 | # imiesłowy bierne czasowników sięicznych: |
92 | 114 | ( |
... | ... | @@ -94,9 +116,10 @@ def make_data(entries): |
94 | 116 | 'haslo': u"g.haslo||' się'", |
95 | 117 | 'entry_placeholders': entry_placeholders, |
96 | 118 | 'main_clause': '''(typods ='ppasver' and l.pos ='ppas' and |
97 | - g.haslosuf <> '')''' | |
119 | + refl.lexemeattributevalue_id <> %s)''', | |
120 | + 'refl': refl_ids, | |
98 | 121 | }, |
99 | - entries | |
122 | + entries + [empty_refl] | |
100 | 123 | ) |
101 | 124 | ] |
102 | 125 | query = ' union all '.join(qp[0] for qp in query_parts) + ''' |
... | ... |