Commit 5e7bf1810b4c953a45dab2fdcd68ad46180d9f63
1 parent
696f1950
eksport: podkreślenia, skróty
Showing
1 changed file
with
17 additions
and
7 deletions
dictionary/export.py
... | ... | @@ -15,6 +15,8 @@ from dictionary.models import CrossReferenceType, ClassificationValue, \ |
15 | 15 | |
16 | 16 | locale.setlocale(locale.LC_ALL, 'pl_PL.utf8') |
17 | 17 | |
18 | +UNDERSCORES = True | |
19 | + | |
18 | 20 | class LexemeExport(object): |
19 | 21 | ADJPREDYKATYWNE = [ |
20 | 22 | u'ciekaw', |
... | ... | @@ -163,8 +165,13 @@ class LexemeExport(object): |
163 | 165 | [self.data['variant']] + list(self.data['vocabs']) + |
164 | 166 | list(self.data['antivocabs'])) |
165 | 167 | |
166 | - self.cv_table = dict( | |
167 | - ClassificationValue.objects.values_list('id', 'label')) | |
168 | + if UNDERSCORES: | |
169 | + self.cv_table = dict( | |
170 | + (id, label.replace(' ', '_')) for id, label | |
171 | + in ClassificationValue.objects.values_list('id', 'label')) | |
172 | + else: | |
173 | + self.cv_table = dict( | |
174 | + ClassificationValue.objects.values_list('id', 'label')) | |
168 | 175 | |
169 | 176 | def queryset(self, pos_set=None): |
170 | 177 | lexemes = Lexeme.objects.filter( |
... | ... | @@ -208,6 +215,8 @@ class LexemeExport(object): |
208 | 215 | i += 1 |
209 | 216 | if self.data['form_qualifiers']: |
210 | 217 | quals = row[i] |
218 | + if UNDERSCORES: | |
219 | + quals = quals.replace(' ', '_') | |
211 | 220 | if self.data['homonym_numbers'] and entry in self.homonym_entries: |
212 | 221 | hn = hn or '' |
213 | 222 | letter = HomonymNumber.MORFEUSZ_LETTERS_REVERSE.get( |
... | ... | @@ -315,11 +324,12 @@ where ls.slownik in (%(vocabs)s) and %(antivocabs)s %(x_qual)s %(table_clause)s |
315 | 324 | for skr in self.queryset(pos_set=self.SKR_POS): |
316 | 325 | entry = skr.entry |
317 | 326 | rozw = skr.attribute_value(self.SKR_ATTR).value |
318 | - pun = entry.endswith('.') | |
319 | - skr_form = entry.rstrip('.') | |
320 | - tag = 'brev:pun' if pun else 'brev:npun' | |
321 | - output_row = (rozw, skr.id, skr_form, tag) | |
322 | - acc.append(output_row) | |
327 | + if all(char not in rozw for char in ',./12'): | |
328 | + pun = entry.endswith('.') | |
329 | + skr_form = entry.rstrip('.') | |
330 | + tag = 'brev:pun' if pun else 'brev:npun' | |
331 | + output_row = (rozw, skr.id, skr_form, tag) | |
332 | + acc.append(output_row) | |
323 | 333 | |
324 | 334 | def export(self): |
325 | 335 | if self.data['homonym_numbers']: |
... | ... |