Commit c3920fdf402d6439937435d60caf1dbf61070449
1 parent
20c673aa
Minor fixes for TEI generator and in change_control2pred_control.py script.
Showing
2 changed files
with
23 additions
and
6 deletions
dictionary/management/commands/change_control2pred_control.py
... | ... | @@ -18,7 +18,6 @@ class Command(BaseCommand): |
18 | 18 | |
19 | 19 | def change_control2pred_control(self): |
20 | 20 | for lemma in Lemma.objects.filter(old=False).order_by('entry_obj__name'): |
21 | - print (lemma) | |
22 | 21 | changes = {'schemata': [], |
23 | 22 | 'schemata2change': [], |
24 | 23 | 'schemata2check': []} |
... | ... | @@ -32,9 +31,10 @@ class Command(BaseCommand): |
32 | 31 | changes['schemata'].append(schema) |
33 | 32 | |
34 | 33 | if changes['schemata2check']: |
35 | - print (lemma, [schema.pk for schema in changes['schemata2check']]) | |
34 | + print u'Poprawić ręcznie:', lemma.entry_obj.name, [schema.pk for schema in changes['schemata2check']] | |
36 | 35 | if changes['schemata2change']: |
37 | - self.save_new_lemma_version(lemma, changes) | |
36 | + new_schemata = self.save_new_lemma_version(lemma, changes) | |
37 | + print u'Zmienione:', lemma.entry_obj.name, [schema.pk for schema in new_schemata] | |
38 | 38 | |
39 | 39 | def schema_need_manual_check(self, schema): |
40 | 40 | if self.control2_type(schema): |
... | ... | @@ -68,14 +68,24 @@ class Command(BaseCommand): |
68 | 68 | |
69 | 69 | def controllee_need_auto_change(self, position): |
70 | 70 | auto_change = False |
71 | - if position.categories.filter(category__startswith='controllee').exists(): | |
71 | + if position.categories.filter(category='controllee').exists(): | |
72 | 72 | auto_change = True |
73 | 73 | for phrase_type in position.arguments.all(): |
74 | 74 | if self.phrase_type_is_infp(phrase_type): |
75 | 75 | auto_change = False |
76 | 76 | return auto_change |
77 | 77 | |
78 | + def phrase_type_is_infp(self, phrase_type): | |
79 | + if (phrase_type.type == 'infp'): | |
80 | + return True | |
81 | + if (phrase_type.type == 'lex' and | |
82 | + phrase_type.atributes.get(type='TYP FRAZY').values.all()[0].argument.type == 'infp'): | |
83 | + return True | |
84 | + return False | |
85 | + | |
78 | 86 | def save_new_lemma_version(self, old_lemma, changes): |
87 | + new_schemata = [] | |
88 | + | |
79 | 89 | admin_user = User.objects.get(username='bniton') |
80 | 90 | |
81 | 91 | old_lemma.old = True |
... | ... | @@ -143,6 +153,7 @@ class Command(BaseCommand): |
143 | 153 | schemata_conversions = [] |
144 | 154 | for old_schema in changes['schemata2change']: |
145 | 155 | new_schema, positions_changes = self.get_or_create_new_schema(old_schema) |
156 | + new_schemata.append(new_schema) | |
146 | 157 | |
147 | 158 | # przepinanie opinii o ramce |
148 | 159 | try: |
... | ... | @@ -206,6 +217,7 @@ class Command(BaseCommand): |
206 | 217 | examples_operations.append(self.connect_example_operation(lu, new_example)) |
207 | 218 | |
208 | 219 | reconnect_examples(new_lemma, examples_operations) |
220 | + return new_schemata | |
209 | 221 | |
210 | 222 | def get_or_create_new_schema(self, old_schema): |
211 | 223 | positions = [] |
... | ... |
dictionary/teixml.py
... | ... | @@ -234,9 +234,10 @@ def write_position_elem(parent_elem, schema_xml_id, position): |
234 | 234 | write_phrases_feature(position_fs_elem, position, position_xml_id) |
235 | 235 | |
236 | 236 | def write_control_features(parent_elem, position): |
237 | - controls1 = position.categories.filter(control=True).exclude(category__endswith='2') | |
237 | + controls1 = position.categories.filter(control=True).exclude(category__endswith='2').exclude(category__startswith='pred') | |
238 | 238 | controls2 = position.categories.filter(control=True, category__endswith='2') |
239 | - if controls1.exists() or controls2.exists(): | |
239 | + pred_controls = position.categories.filter(control=True, category__startswith='pred') | |
240 | + if controls1.exists() or controls2.exists() or pred_controls.exists(): | |
240 | 241 | control_f_elem = etree.SubElement(parent_elem, 'f') |
241 | 242 | control_f_elem.attrib['name'] = 'control' |
242 | 243 | vColl_elem = etree.SubElement(control_f_elem, 'vColl') |
... | ... | @@ -249,6 +250,10 @@ def write_control_features(parent_elem, position): |
249 | 250 | control = controls2[0].category |
250 | 251 | control2_symbol_elem = etree.SubElement(vColl_elem, 'symbol') |
251 | 252 | control2_symbol_elem.attrib['value'] = control |
253 | + if pred_controls.exists(): | |
254 | + control = pred_controls[0].category | |
255 | + pred_controls_symbol_elem = etree.SubElement(vColl_elem, 'symbol') | |
256 | + pred_controls_symbol_elem.attrib['value'] = control | |
252 | 257 | |
253 | 258 | def write_phrases_feature(parent_elem, position, position_xml_id): |
254 | 259 | sorted_phrases = sortArguments(position.arguments.all()) |
... | ... |