Commit 9f88827ccf29e0901522d9917a2c51ada757c969
1 parent
8d5f92e9
Minor changes to TEI, TEX and Textual output formats.
Showing
5 changed files
with
67 additions
and
44 deletions
dictionary/ajax_vocabulary_management.py
... | ... | @@ -155,6 +155,8 @@ def create_text_walenty(file_name, lemmas, vocabularies, frame_opinions, |
155 | 155 | pred_val=pred_val, |
156 | 156 | aspect_val=aspect_val).order_by('text_rep') |
157 | 157 | for frame in matching_frames: |
158 | + if not lemma.phraseology_ready() and frame.phraseologic: | |
159 | + continue | |
158 | 160 | if not frame_opinions or founded_frame_opinions.filter(frame=frame).exists(): |
159 | 161 | text_rep = frame.get_position_spaced_text_rep() |
160 | 162 | if add_frame_opinions: |
... | ... |
dictionary/models.py
... | ... | @@ -250,6 +250,20 @@ class Lemma(Model): |
250 | 250 | except Frame_Opinion.DoesNotExist: |
251 | 251 | pass |
252 | 252 | return frame_opinion_name |
253 | + | |
254 | + def phraseology_ready(self): | |
255 | + actual_status = self.status | |
256 | + ready_f_status = Lemma_Status.objects.get(type__sym_name='ready_f') | |
257 | + if actual_status.priority >= ready_f_status.priority: | |
258 | + return True | |
259 | + return False | |
260 | + | |
261 | + def semantics_ready(self): | |
262 | + actual_status = self.status | |
263 | + ready_s_status = Lemma_Status.objects.get(type__sym_name='ready_s') | |
264 | + if actual_status.priority >= ready_s_status.priority: | |
265 | + return True | |
266 | + return False | |
253 | 267 | |
254 | 268 | class Meta: |
255 | 269 | db_table = 'hasla' |
... | ... |
dictionary/teixml.py
... | ... | @@ -26,7 +26,6 @@ File with functions responsible for creating TEI xml. |
26 | 26 | ''' |
27 | 27 | |
28 | 28 | import datetime |
29 | -import operator | |
30 | 29 | |
31 | 30 | from lxml import etree |
32 | 31 | from xml.sax.saxutils import escape |
... | ... | @@ -41,7 +40,7 @@ XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace' |
41 | 40 | def createteixml(outpath, lemmas, frame_opinion_values): |
42 | 41 | root = write_root() |
43 | 42 | write_header(root) |
44 | - #lemmas = lemmas.filter(entry=u'brnąć') | |
43 | + #lemmas = lemmas.filter(entry=u'żywić') | |
45 | 44 | write_entries(root, lemmas, frame_opinion_values) |
46 | 45 | with open(outpath, 'w') as output_file: |
47 | 46 | output_file.write(etree.tostring(root, pretty_print=True, |
... | ... | @@ -92,9 +91,10 @@ def write_entry(body_elem, lemma, frame_opinions, frame_opinion_values): |
92 | 91 | |
93 | 92 | write_syntactic_layer(entry_elem, lemma, frame_opinions, frame_opinion_values) |
94 | 93 | write_examples_layer(entry_elem, lemma) |
95 | - write_semantic_layer(entry_elem, lemma) | |
96 | - write_meanings_layer(entry_elem, lemma) | |
97 | - write_connections_layer(entry_elem, lemma) | |
94 | + if lemma.semantics_ready(): | |
95 | + write_semantic_layer(entry_elem, lemma) | |
96 | + write_meanings_layer(entry_elem, lemma) | |
97 | + write_connections_layer(entry_elem, lemma) | |
98 | 98 | |
99 | 99 | def write_syntactic_layer(entry_elem, lemma, frame_opinions, frame_opinion_values): |
100 | 100 | synt_layer_fs_elem = etree.SubElement(entry_elem, 'fs') |
... | ... | @@ -113,12 +113,12 @@ def write_syntactic_layer(entry_elem, lemma, frame_opinions, frame_opinion_value |
113 | 113 | pred_val=pred_val, |
114 | 114 | aspect_val=aspect_val).order_by('text_rep') |
115 | 115 | for frame in matchingframes: |
116 | - if (not frame_opinion_values.exists() or | |
117 | - frame_opinions.filter(frame=frame).exists()): | |
116 | + if not lemma.phraseology_ready() and frame.phraseologic: | |
117 | + continue | |
118 | + if (not frame_opinion_values.exists() or frame_opinions.filter(frame=frame).exists()): | |
118 | 119 | write_schema(vColl_elem, frame, lemma) |
119 | 120 | |
120 | 121 | def write_schema(parent_elem, schema, lemma): |
121 | - | |
122 | 122 | schema_xml_id = 'wal_%s.%s-sch' % (str(lemma.entry_obj.id), str(schema.id)) |
123 | 123 | |
124 | 124 | schema_fs_elem = etree.SubElement(parent_elem, 'fs') |
... | ... | @@ -420,20 +420,24 @@ def write_examples_layer(parent_elem, lemma): |
420 | 420 | write_examples_feature(vColl_elem, lemma) |
421 | 421 | |
422 | 422 | def write_examples_feature(parent_elem, lemma): |
423 | - entry = lemma.entry_obj | |
424 | 423 | for example in lemma.nkjp_examples.order_by('opinion__priority').all(): |
425 | - write_example(parent_elem, entry, example) | |
424 | + if not lemma.phraseology_ready() and example.frame.phraseologic: | |
425 | + pass | |
426 | + else: | |
427 | + write_example(parent_elem, lemma, example) | |
426 | 428 | for example in lemma.lemma_nkjp_examples.order_by('opinion__priority').all(): |
427 | - write_example(parent_elem, entry, example) | |
429 | + write_example(parent_elem, lemma, example) | |
428 | 430 | |
429 | -def write_example(parent_elem, entry, example): | |
431 | +def write_example(parent_elem, lemma, example): | |
432 | + entry = lemma.entry_obj | |
430 | 433 | example_xml_id = u'wal_%s.%s-exm' % (str(entry.id), str(example.id)) |
431 | 434 | |
432 | 435 | example_fs_elem = etree.SubElement(parent_elem, 'fs') |
433 | 436 | example_fs_elem.attrib[etree.QName(XML_NAMESPACE, 'id')] = example_xml_id |
434 | 437 | example_fs_elem.attrib['type'] = 'example' |
435 | 438 | |
436 | - get_and_write_meaning_link(example_fs_elem, entry, example) | |
439 | + if lemma.semantics_ready(): | |
440 | + get_and_write_meaning_link(example_fs_elem, entry, example) | |
437 | 441 | write_phrases_links(example_fs_elem, entry, example) |
438 | 442 | |
439 | 443 | sentence_f_elem = etree.SubElement(example_fs_elem, 'f') |
... | ... | @@ -519,9 +523,19 @@ def write_frame_fs(parent_elem, entry, frame): |
519 | 523 | frame_fs_elem.attrib[etree.QName(XML_NAMESPACE, 'id')] = frame_xml_id |
520 | 524 | frame_fs_elem.attrib['type'] = 'frame' |
521 | 525 | |
526 | + write_frame_opinion(frame_fs_elem, frame) | |
522 | 527 | write_frame_meanings(frame_fs_elem, entry, frame) |
523 | 528 | write_frame_arguments(frame_fs_elem, entry, frame) |
524 | 529 | |
530 | +def write_frame_opinion(parent_elem, frame): | |
531 | + frame_opinion = 'unk' | |
532 | + if frame.opinion_selected(): | |
533 | + frame_opinion = frame.opinion.short | |
534 | + opinion_f_elem = etree.SubElement(parent_elem, 'f') | |
535 | + opinion_f_elem.attrib['name'] = 'opinion' | |
536 | + opinion_symbol = etree.SubElement(opinion_f_elem, 'symbol') | |
537 | + opinion_symbol.attrib['value'] = frame_opinion | |
538 | + | |
525 | 539 | def write_frame_meanings(parent_elem, entry, frame): |
526 | 540 | meanings_f_elem = etree.SubElement(parent_elem, 'f') |
527 | 541 | meanings_f_elem.attrib['name'] = 'meanings' |
... | ... | @@ -734,39 +748,30 @@ def write_connections_layer(parent_elem, lemma): |
734 | 748 | def write_alternations(parent_elem, lemma): |
735 | 749 | entry = lemma.entry_obj |
736 | 750 | frames = entry.actual_frames() |
737 | - | |
738 | 751 | for schema in lemma.frames.all(): |
739 | 752 | for frame in frames: |
740 | 753 | matching_complements = frame.complements.filter(realizations__frame=schema).distinct() |
741 | - if matching_complements.filter(realizations__alternation=1).exists(): | |
742 | - alternation_fs_elem = etree.SubElement(parent_elem, 'fs') | |
743 | - alternation_fs_elem.attrib['type'] = 'alternation' | |
744 | - | |
745 | - connections_f_elem = etree.SubElement(alternation_fs_elem, 'f') | |
746 | - connections_f_elem.attrib['name'] = 'connections' | |
747 | - | |
748 | - vColl_elem = etree.SubElement(connections_f_elem, 'vColl') | |
749 | - vColl_elem.attrib['org'] = 'set' | |
750 | - | |
751 | - for arg in frame.complements.all(): | |
752 | - alt_realizations = arg.realizations.filter(frame=schema, alternation=1) | |
753 | - if alt_realizations.exists(): | |
754 | - write_connection(vColl_elem, entry, frame, arg, alt_realizations) | |
755 | - | |
756 | - if matching_complements.filter(realizations__alternation=2).exists(): | |
757 | - alternation_fs_elem = etree.SubElement(parent_elem, 'fs') | |
758 | - alternation_fs_elem.attrib['type'] = 'alternation' | |
759 | - | |
760 | - connections_f_elem = etree.SubElement(alternation_fs_elem, 'f') | |
761 | - connections_f_elem.attrib['name'] = 'connections' | |
762 | - | |
763 | - vColl_elem = etree.SubElement(connections_f_elem, 'vColl') | |
764 | - vColl_elem.attrib['org'] = 'set' | |
765 | - | |
766 | - for arg in frame.complements.all(): | |
767 | - alt_realizations = arg.realizations.filter(frame=schema, alternation=2) | |
768 | - if alt_realizations.exists(): | |
769 | - write_connection(vColl_elem, entry, frame, arg, alt_realizations) | |
754 | + write_alternation(parent_elem, entry, schema, frame, matching_complements, 1) | |
755 | + write_alternation(parent_elem, entry, schema, frame, matching_complements, 2) | |
756 | + | |
757 | +def write_alternation(parent_elem, entry, schema, frame, complements, alternation): | |
758 | + alternation_compls = complements.filter(realizations__alternation=alternation) | |
759 | + if alternation_compls.exists(): | |
760 | + first_connection = True | |
761 | + for arg in alternation_compls.all(): | |
762 | + alt_realizations = arg.realizations.filter(frame=schema, alternation=alternation) | |
763 | + if alt_realizations.exists(): | |
764 | + if first_connection: | |
765 | + alternation_fs_elem = etree.SubElement(parent_elem, 'fs') | |
766 | + alternation_fs_elem.attrib['type'] = 'alternation' | |
767 | + | |
768 | + connections_f_elem = etree.SubElement(alternation_fs_elem, 'f') | |
769 | + connections_f_elem.attrib['name'] = 'connections' | |
770 | + | |
771 | + vColl_elem = etree.SubElement(connections_f_elem, 'vColl') | |
772 | + vColl_elem.attrib['org'] = 'set' | |
773 | + first_connection = False | |
774 | + write_connection(vColl_elem, entry, frame, arg, alt_realizations) | |
770 | 775 | |
771 | 776 | def write_connection(parent_elem, entry, frame, arg, realizations): |
772 | 777 | connection_fs_elem = etree.SubElement(parent_elem, 'fs') |
... | ... |
dictionary/templates/tex/slowal.tex
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | \begin{document} |
49 | 49 | |
50 | 50 | {% for lemma in lemmas %} |
51 | - {% lemma_tex lemma forloop.counter0 q_frame_opinions sort_reflex_vals sort_aspect_vals sort_neg_vals sort_pred_vals download_dict %} | |
51 | + {% lemma_tex lemma forloop.counter0 q_frame_opinions download_dict %} | |
52 | 52 | {% endfor %} |
53 | 53 | |
54 | 54 | \end{document} |
... | ... |
dictionary/templatetags/tex_tags.py
... | ... | @@ -103,6 +103,8 @@ def lemma_tex(lemma, loop_counter, q_frame_opinions, download_dict): |
103 | 103 | pred_val=pred_val, |
104 | 104 | aspect_val=aspect_val).order_by('text_rep') |
105 | 105 | for frame in matching_frames: |
106 | + if not lemma.phraseology_ready() and frame.phraseologic: | |
107 | + continue | |
106 | 108 | if not download_dict['frame_opinions'] or (frame_opinions and frame_opinions.filter(frame=frame).count() > 0): |
107 | 109 | frames.append(frame) |
108 | 110 | return {'lemma': lemma, |
... | ... |