Commit 114f2ca19bd4f703c2a84d9e3f1ea48cec755029
1 parent
419e00a8
poprawione pl:gen:f w interfejsie WSJP
Showing
1 changed file
with
28 additions
and
16 deletions
dictionary/wsjp.py
... | ... | @@ -8,7 +8,7 @@ BASE_QUERY = ''' |
8 | 8 | select distinct pref||rdzen||zak||suf slowo, %(haslo_tab)s, hom, |
9 | 9 | l.pos, |
10 | 10 | case when l.pos in ('subst','osc','v') then p.charfl else '' end |
11 | - as rodzaj, podparad, row, col, rowspan, colspan, kskl | |
11 | + as rodzaj, podparad, %(row)s, col, rowspan, colspan, kskl | |
12 | 12 | from |
13 | 13 | odmieniasie o |
14 | 14 | join leksemy l on (o.l_id = l.id) |
... | ... | @@ -87,75 +87,87 @@ def make_data(entry): |
87 | 87 | params = [] |
88 | 88 | for lip in lips: |
89 | 89 | charfl = get_charfl(lip) |
90 | - | |
90 | + pattern = lip.pattern | |
91 | + fnuni = pattern.endings.filter(base_form_label__symbol='pl:gen:fnuni').exists() | |
92 | + funi = pattern.endings.filter(base_form_label__symbol='pl:gen:funi').exists() | |
93 | + if fnuni and not funi: | |
94 | + row = '''case when row = 5 and col = 3 then 4 else row end''' | |
95 | + else: | |
96 | + row = 'row' | |
97 | + common_fields = { | |
98 | + 'refl': refl_ids, | |
99 | + 'row': row, | |
100 | + } | |
91 | 101 | query_parts = [ |
92 | 102 | ( |
93 | - BASE_QUERY % { | |
103 | + BASE_QUERY, | |
104 | + { | |
94 | 105 | 'haslo_tab': 'haslo', |
95 | 106 | 'haslo': 'haslo', |
96 | 107 | 'leks_clause': '''l.pos not in ('skrl','skrw') and |
97 | 108 | (l.pos != 'v' or refl.attribute_value_id in (%s))''' % nonrefl_ids, |
98 | - 'refl': refl_ids, | |
99 | 109 | }, |
100 | 110 | [charfl, lip.id, '1'] |
101 | 111 | ), |
102 | 112 | # czasowniki sięiczne: |
103 | 113 | ( |
104 | - BASE_QUERY % { | |
114 | + BASE_QUERY, | |
115 | + { | |
105 | 116 | 'haslo_tab': u"haslo||' się'", |
106 | 117 | 'haslo': 'haslo', |
107 | 118 | 'leks_clause': '''(l.pos='v' and refl.attribute_value_id <> %s)''', |
108 | - 'refl': refl_ids, | |
109 | 119 | }, |
110 | 120 | [charfl, lip.id, empty_refl, 's'] |
111 | 121 | ), |
112 | 122 | # czasowniki zanegowane: |
113 | 123 | ( |
114 | - BASE_QUERY % { | |
124 | + BASE_QUERY, | |
125 | + { | |
115 | 126 | 'haslo_tab': "'nie '||haslo", |
116 | 127 | 'haslo': "'nie '||haslo", |
117 | 128 | 'leks_clause': '''l.pos='v' and refl.attribute_value_id in (%s)''' |
118 | 129 | % nonrefl_ids, |
119 | - 'refl': refl_ids, | |
120 | 130 | }, |
121 | 131 | [charfl, lip.id, 'n'] |
122 | 132 | ), |
123 | 133 | # czasowniki sięiczne zanegowane: |
124 | 134 | ( |
125 | - BASE_QUERY % { | |
135 | + BASE_QUERY, | |
136 | + { | |
126 | 137 | 'haslo_tab': u"'nie '||haslo||' się'", |
127 | 138 | 'haslo': "'nie '||haslo", |
128 | 139 | 'leks_clause': '''(l.pos='v' and refl.attribute_value_id <> %s)''', |
129 | - 'refl': refl_ids, | |
130 | 140 | }, |
131 | 141 | [charfl, lip.id, empty_refl, 'ns'] |
132 | 142 | ), |
133 | 143 | # wymagające gniazdowania: adjcom, advcom i ppas |
134 | 144 | ( |
135 | - NESTED_BASE % { | |
145 | + NESTED_BASE, | |
146 | + { | |
136 | 147 | 'haslo': 'g.haslo', |
137 | 148 | 'main_clause': '''typods in ('comadj','comadv','ppasver') and |
138 | 149 | l.pos in ('adjcom','advcom','ppas') and |
139 | 150 | (l.pos != 'ppas' or refl.attribute_value_id in (%s))''' |
140 | 151 | % nonrefl_ids, |
141 | - 'refl': refl_ids, | |
142 | 152 | }, |
143 | 153 | [charfl, lip.lexeme_id] |
144 | 154 | ), |
145 | 155 | # imiesłowy bierne czasowników sięicznych: |
146 | 156 | ( |
147 | - NESTED_BASE % { | |
157 | + NESTED_BASE, | |
158 | + { | |
148 | 159 | 'haslo': u"g.haslo||' się'", |
149 | 160 | 'main_clause': '''(typods ='ppasver' and l.pos ='ppas' and |
150 | 161 | refl.attribute_value_id <> %s)''', |
151 | - 'refl': refl_ids, | |
152 | 162 | }, |
153 | 163 | [charfl, lip.lexeme_id, empty_refl] |
154 | 164 | ) |
155 | 165 | ] |
156 | - subqueries.extend(qp[0] for qp in query_parts) | |
166 | + subqueries.extend( | |
167 | + qp[0] % dict(common_fields.items() + qp[1].items()) | |
168 | + for qp in query_parts) | |
157 | 169 | for qp in query_parts: |
158 | - params += qp[1] | |
170 | + params += qp[2] | |
159 | 171 | cursor = connection.cursor() |
160 | 172 | cursor.execute(' union all '.join(subqueries) + ''' |
161 | 173 | order by haslo, hom, rodzaj, podparad, row, col, kskl, slowo |
... | ... |