diff --git a/data/unification/unify_example_small.xml b/data/unification/unify_example_small.xml index e03f8b0fb10dd23d20b93386c8ae55844aed2d21..3276082d1dfed76e739c8a8a62de969d315e3275 100644 --- a/data/unification/unify_example_small.xml +++ b/data/unification/unify_example_small.xml @@ -8,12 +8,11 @@ </roles> </argument> <argument id="2"> - <semantic_role type="alernative"> - <roles> - <role name="Theme"/> - <role name="Recipient"/> - </roles> - </semantic_role> + <semantic_role type="alernative"/> + <roles> + <role name="Theme"/> + <role name="Recipient"/> + </roles> </argument> <argument id="3"> <semantic_role type="role"/> diff --git a/entries/static/entries/css/unification_frames.css b/entries/static/entries/css/unification_frames.css new file mode 100644 index 0000000000000000000000000000000000000000..aa160a9e054bcf01375029f49d62f750bf6cef10 --- /dev/null +++ b/entries/static/entries/css/unification_frames.css @@ -0,0 +1,24 @@ +table.table-button-menu { + border-style:solid; + border-width:1px; + border-right: 1px solid #000; + border-color: #c3d2d9; + width: 100% +} + +table.table-button-menu td { + border-style:solid; + border-width:1px; + border-right: 1px solid #000; + border-color: #c3d2d9; + +} + +table.table-button-menu td:hover { + background-color: #e8ebed; + cursor: pointer; +} + +.preference-bold { + font-weight: bold; +} diff --git a/entries/static/entries/js/entries.js b/entries/static/entries/js/entries.js index 8781a38a6d21b87d5c181e6bf4a21c2e0d0687de..6970a543d94caec865b6697e1821a9608dd91411 100644 --- a/entries/static/entries/js/entries.js +++ b/entries/static/entries/js/entries.js @@ -8,7 +8,6 @@ var curr_realisation_phrases = null; var curr_realisation_descriptions = null; var curr_examples = null; var curr_examples_by_id = null; -var frame_content; function make_opinion_row(item, span, width) { var opinion_row = document.createElement('tr'); @@ -103,18 +102,13 @@ function subentries2dom(subentries) { return fragment; } -function frame2dom(frame) { - var div = document.createElement('div'); - div.className = 'frame mb-3'; - div.setAttribute('data-frame_id', frame.id); - - var p = document.createElement('p'); - p.className = 'mb-1' +function lexical_units2dom(lexical_units_objects) { + var lexical_units = []; - for (var i in frame.lexical_units) { - var lu = frame.lexical_units[i]; + for (var i in lexical_units_objects) { + var lu = lexical_units_objects[i]; var cls = lu.entry_meaning ? ' entry-meaning' : ''; - var lu_html = '<span class="lexical-unit' + cls + '" data-lu_id="' + lu.id + '">' + lu.str + '</span>'; + var lu_html = '<span class="lexical-unit' + cls + '" data-lu_id="' + lu.id + '">' + lu.str + '</span>'; var tooltip = []; if (lu.definition) { tooltip.push(lu.definition); @@ -135,9 +129,21 @@ function frame2dom(frame) { } lexical_units.push(lu_html); } - p.innerHTML = lexical_units.join(', '); + + return lexical_units.join(', '); +} + +function frame2dom(frame) { + var div = document.createElement('div'); + div.className = 'frame mb-3'; + div.setAttribute('data-frame_id', frame.id); + + var lexical_units_html = lexical_units2dom(frame.lexical_units); + var p = document.createElement('p'); + p.className = 'mb-1' + p.innerHTML = lexical_units_html; div.append(p) - + var table = document.createElement('table'); table.className = 'table m-0 table-borderless border border-secondary text-dark'; var tbody = document.createElement('tbody'); @@ -802,7 +808,6 @@ function get_entry(entry_id, related) { data : data, timeout : 60000, success : function(response) { - frame_content = response.frames; curr_entry = entry_id; curr_no_filters = related; clear_info(); diff --git a/entries/static/entries/js/selectional_preference.js b/entries/static/entries/js/selectional_preference.js index d4a14e4d01b921afaa4a847c8b8fe9acf6eba0d9..a802f135a18c7ecc89d74e3c3f70833b95904a7e 100644 --- a/entries/static/entries/js/selectional_preference.js +++ b/entries/static/entries/js/selectional_preference.js @@ -119,7 +119,11 @@ function attachPlWNContextAutocomplete() { }); } -function addSelectivePreference(frame, complement_id) { +function addSelectivePreference() { + addSelectivePreferenceBase(unified_view_frame_content[0], 1) +} + +function addSelectivePreferenceBase(frame, complement_id) { let unified_frame_id = frame.id; @@ -150,7 +154,7 @@ function addSelectivePreference(frame, complement_id) { if (v == -1) { e.preventDefault(); - get_entry(curr_entry, false); + get_unified_frame(curr_entry, false); $.prompt.close(); } diff --git a/entries/static/entries/js/unification.js b/entries/static/entries/js/unification.js index 0778742656db5d64669010b92d2ab2fe2a706285..516919ea016447ba8e380821f262d9b648054daa 100644 --- a/entries/static/entries/js/unification.js +++ b/entries/static/entries/js/unification.js @@ -1,5 +1,6 @@ "use strict"; +var unified_view_frame_content; function get_unified_frame(unified_frame_id, related) { check_import_status(); @@ -14,7 +15,7 @@ function get_unified_frame(unified_frame_id, related) { data : data, timeout : 60000, success : function(response) { - frame_content = response.frames; + unified_view_frame_content = response.frames; curr_entry = unified_frame_id; curr_no_filters = related; clear_info(); @@ -27,10 +28,10 @@ function get_unified_frame(unified_frame_id, related) { curr_examples_by_id[curr_examples[i].id] = curr_examples[i]; } // show_syntax(response.subentries); - show_unified_frame(response.unified_frame) + show_unified_frame(response.unified_frame, response.frames) show_unified_frame_lexical_units(response.frames) show_semantics(response.frames, response.subentries); - show_unmatched_examples(); + // show_unmatched_examples(); // if current tab is empty, switch to an active tab var active_tab = $('#entryTabs').find('.nav-link.active').attr('id'); @@ -60,57 +61,87 @@ function get_unified_frame(unified_frame_id, related) { } -function unifiedFrame2dom(frame) { +function slowal_frames2selecional_preferencies(unified_frame, slowal_frames) { + var unified_argument_2_selecional_preferencies = {} + for (var i in unified_frame.slowal_frame_mapping) { + var slowal_frame_mapping = unified_frame.slowal_frame_mapping[i]; + let slowal_frame = slowal_frames.find(o => o.id === slowal_frame_mapping.slowal_frame_id); + for (var j in slowal_frame_mapping.slowal_frame_argument_mapping) { + var slowal_frame_argument_mapping = slowal_frame_mapping.slowal_frame_argument_mapping[j]; + + let slowal_frame_argument = slowal_frame.arguments.find(o => o.argument_id === slowal_frame_argument_mapping.slowal_frame_agrument_id); + + let preferenceEntry = unified_argument_2_selecional_preferencies[slowal_frame_argument_mapping.unified_frame_agrument_id]; + if(preferenceEntry == null) { + preferenceEntry = []; + unified_argument_2_selecional_preferencies[slowal_frame_argument_mapping.unified_frame_agrument_id] = preferenceEntry + } + preferenceEntry.push.apply(preferenceEntry, slowal_frame_argument.preferences) + } + } + return unified_argument_2_selecional_preferencies; +} + +function unifiedFrame2dom(unifiedFrame, slowal_frames) { var div = document.createElement('div'); - div.className = 'frame mb-3'; - div.setAttribute('data-frame_id', frame.id); + div.className = 'unifiedFrame mb-3'; + div.setAttribute('data-frame_id', unifiedFrame.id); var p = document.createElement('p'); p.className = 'mb-1' - p.innerHTML = '<span class="lexical-unit' + cls + '">' + frame.title + '</span>'; + let title = unifiedFrame.title; + if(title == null) { + //title as list of lexical units from all slowal frames + var lexical_units = frames2lexical_units(slowal_frames); + var lexical_units_html = lexical_units2dom(lexical_units); + title = lexical_units_html; + } + + p.innerHTML = '<span class="lexical-unit' + cls + '">' + title + '</span>'; div.append(p) + let slowal_frames2selecional_preferencies_mapping = slowal_frames2selecional_preferencies(unifiedFrame, slowal_frames); + var table = document.createElement('table'); table.className = 'table m-0 table-borderless border border-secondary text-dark'; var tbody = document.createElement('tbody'); // roles and selectional preferences var roles_row = document.createElement('tr'); - roles_row.innerHTML = '<th scope="row" class="py-2 px-1 text-secondary">' + gettext('Rola') + '</td>'; + var roles_html = '<th scope="row" class="py-2 px-1 text-secondary">' + gettext('Rola') + '</td>'; var preferences_row = document.createElement('tr'); var preferences_html = '<th scope="row" class="py-0 px-1 text-secondary">' + gettext('Preferencje selekcyjne') + '</td>'; - for (var i in frame.arguments) { - var argument = frame.arguments[i]; + for (var i in unifiedFrame.arguments) { + var argument = unifiedFrame.arguments[i]; var cls = ''; var data = ' data-argument_id="' + argument.id + '" data-role="' + argument.role + '"'; - roles_row.innerHTML += '<td class="argument py-2 px-1 border-top border-left border-secondary' + cls + ' ' + argument.role + '"' + data + '>' + argument.str + '</td>'; + roles_html += '<td class="argument py-2 px-1 border-top border-left border-secondary' + cls + ' ' + argument.role_type + '"' + data + '>' + argument.role_type; + roles_html += '<ul>' + for (var j in argument.proposed_roles) { + var proposed_role = argument.proposed_roles[j]; + roles_html += '<li>' + proposed_role.role + '</li>'; + } + roles_html += '</ul>' + roles_html += '</td>' - // don’t append to preferences_html.innerHTML since it automatically closes tags *** (?) preferences_html += '<td class="preferences py-0 px-0 border-top border-left border-secondary' + cls + '"' + data + '>' - for (var j in argument.preferences) { - var preference = argument.preferences[j]; - var cls = j > 0 ? ' border-top' : ''; - if (preference.str.length > 12) { - cls += ' text-break'; - } - preferences_html += '<div class="preference py-2 px-1' + cls + '">'; - if (preference.url) { -// preferences_html += ' <a class="synset-plwn" href="' + preference.url + '" target="_blank"><img src="' + window.STATIC_URL + 'common/img/ext-link.svg" alt="external link" height="14"/></a>'; - preferences_html += ' <a class="synset-plwn" href="' + preference.url + '" target="_blank">' + preference.str + '</a>'; - } else { - preferences_html += preference.str; - } - if (preference.info) { - preferences_html += ' ' + tooltipped_info(preference.info); - } - preferences_html += '</div>'; + + // don’t append to preferences_html.innerHTML since it automatically closes tags *** (?) + let selectional_preference_html = create_selectional_preference_html(argument.preferences, 'preference-bold'); + preferences_html += selectional_preference_html; + + let selecional_preferencies_poposition = slowal_frames2selecional_preferencies_mapping[argument.id] + if(selecional_preferencies_poposition != null) { + let selectional_preference_proposition_html = create_selectional_preference_html(selecional_preferencies_poposition, ''); + preferences_html += selectional_preference_proposition_html; } + // *** and we want to close the <td> here preferences_html += '</td>'; } preferences_row.innerHTML += preferences_html; - + roles_row.innerHTML = roles_html; tbody.append(roles_row); tbody.append(preferences_row); table.append(tbody); @@ -119,10 +150,30 @@ function unifiedFrame2dom(frame) { return div; } +function create_selectional_preference_html(preferences, additioan_css_class) { + let preferences_html_local = ''; + for (var j in preferences) { + var preference = preferences[j]; + var cls = j > 0 ? ' border-top' : ''; + if (preference.str.length > 12) { + cls += ' text-break'; + } + preferences_html_local += '<div class="preference py-2 px-1' + cls + '">'; + if (preference.url) { + preferences_html_local += ' <a class="synset-plwn '+additioan_css_class+'" href="' + preference.url + '" target="_blank">' + preference.str + '</a>'; + } else { + preferences_html_local += ' <span class="'+additioan_css_class+'">' + preference.str +'</span>'; + } + if (preference.info) { + preferences_html_local += ' ' + tooltipped_info(preference.info); + } + preferences_html_local += '</div>'; + } + return preferences_html_local; +} + function frames2lexical_units(frames) { - var div = document.createElement('div'); - div.className = 'frame mb-3'; var lexical_units = [] for (var i in frames) { var frame = frames[i]; @@ -132,11 +183,17 @@ function frames2lexical_units(frames) { lexical_units.push(lexical_unit); } } + return lexical_units; +} + +function frames2lexical_unitsHTML(frames) { + var div = document.createElement('div'); + div.className = 'frame mb-3'; + var lexical_units = frames2lexical_units(frames) var table = document.createElement('table'); table.className = 'table m-0 table-borderless border border-secondary text-dark'; var tbody = document.createElement('tbody'); - // roles and selectional preferences var header_row = document.createElement('tr'); header_row.innerHTML += '<th scope="row" class="py-2 px-1 text-secondary">' + gettext('Jednostka leksykalna') + '</td>'; header_row.innerHTML += '<th scope="row" class="py-2 px-1 text-secondary">' + gettext('Opinia') + '</td>'; @@ -155,14 +212,14 @@ function frames2lexical_units(frames) { return div; } -function show_unified_frame(unified_frame) { - var unified_frame_dom = unifiedFrame2dom(unified_frame); +function show_unified_frame(unified_frame, slowal_frames) { + var unified_frame_dom = unifiedFrame2dom(unified_frame, slowal_frames); $('#unified-frame').empty(); $('#unified-frame').append($(unified_frame_dom)); } function show_unified_frame_lexical_units(frames) { - var lexical_units_dom = frames2lexical_units(frames); + var lexical_units_dom = frames2lexical_unitsHTML(frames); $('#unified-frame-lexical-units').empty(); $('#unified-frame-lexical-units').append($(lexical_units_dom)); } diff --git a/entries/templates/entries_base.html b/entries/templates/entries_base.html index 3ab1544e4bbec908d032b55ae673c51ce5d1118e..8561a7bc1bde979d8dbed03beb9509ac2d8ddfa4 100644 --- a/entries/templates/entries_base.html +++ b/entries/templates/entries_base.html @@ -25,7 +25,6 @@ <script src="{% static 'entries/js/forms.js' %}"></script> <script src="{% static 'entries/js/utils.js' %}"></script> <script src="{% static 'entries/js/selectional_preference.js' %}"></script> - <script src="{% static 'entries/js/jquery-impromptu.min.js' %}"></script> <script src="{% static 'entries/js/entries.js' %}"></script> {% endblock %} diff --git a/entries/templates/unification_edit_display.html b/entries/templates/unification_edit_display.html new file mode 100644 index 0000000000000000000000000000000000000000..9fbd7434b79638ba1b59c9649d77a30bafdcb75d --- /dev/null +++ b/entries/templates/unification_edit_display.html @@ -0,0 +1,101 @@ +{% load i18n %} + +<div class="tab-content h-100 w-100 p-0" id="entryTabsContent"> + <div class="col h-100 w-100 p-0 tab-pane show active" id="semantics" role="tabpanel" aria-labelledby="semantics-tab"> + <div class="row m-0 p-0" id="semantics-top-pane"> + <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-frames-pane"> + <table class="table-button-menu" cellspacing="1"> + <tr style="background-color: white;"> + <td id="change-title" style="padding: 10px 15px 10px 15px; color: #000000;"> + Zmień nazwę + </td> + <td id="add-arg" style="padding: 10px 15px 10px 15px; color: #000000;"> + Dodaj argum. + </td> + <td id="add-pref" style="padding: 10px 15px 10px 15px; color: #000000;" + onclick="addSelectivePreference()"> + Dodaj prefer. + </td> + <td id="merge" style="padding: 10px 15px 10px 15px; color: #000000;"> + Scal + </td> + <td id="ready" style="padding: 10px 15px 10px 15px; color: #000000;"> + Gotowe + </td> + </tr> + <tr style="background-color: white;"> + <td id="change-role" style="padding: 10px 15px 10px 15px; color: #000000;"> + Zmień rolę + </td> + <td id="remove-arg" style="padding: 10px 15px 10px 15px; color: #000000;"> + Usuń argum. + </td> + <td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;"> + Zamień okna + </td> + <td id="duplicates" style="padding: 10px 15px 10px 15px; color: #000000;"> + Duplikuj + </td> + <td id="save-changes" style="padding: 10px 15px 10px 15px; color: #000000;"> + Zapisz + </td> + </tr> + </table> + <br> + <div id="unified-frame"></div> + <div id="unified-frame-lexical-units"></div> + <div id="semantics-frames"></div> + </div> + <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-schemata-pane"> + <div id="semantics-schemata"></div> + </div> + </div> + <div class="row m-0 p-0 overflow-auto" id="semantics-examples-pane"> + <table id="semantics-examples" class="table table-sm table-hover"> + <thead> + <tr> + <th scope="col">{% trans "Przykład" %}<i id="examples-argument"></i><i id="examples-lu"></i><i id="examples-schema"></i></th> + <th scope="col">{% trans "Źródło" %}</th> + <th scope="col">{% trans "Opinia" %}</th> + </tr> + </thead> + <tbody id="semantics-examples-list"> + </tbody> + </table> + <p class="mx-1 my-1"id="semantics-no-examples">{% trans "Brak przykładów" %}</p> + </div> + </div> + <div class="col h-100 w-100 p-0 tab-pane" id="syntax" role="tabpanel" aria-labelledby="syntax-tab"> + <div class="col w-100 px-1 pt-0 pb-0 overflow-auto" id="syntax-schemata-pane"> + <div id="syntax-schemata"></div> + </div> + <div class="col w-100 p-0 overflow-auto" id="syntax-examples-pane"> + <table id="syntax-examples" class="table table-sm table-hover"> + <thead> + <tr> + <th scope="col">{% trans "Przykład" %}</th> + <th scope="col">{% trans "Źródło" %}</th> + <th scope="col">{% trans "Opinia" %}</th> + </tr> + </thead> + <tbody id="syntax-examples-list"> + </tbody> + </table> + <p class="mx-1 my-1"id="syntax-no-examples">{% trans "Brak przykładów" %}</p> + </div> + </div> + <div class="col h-100 w-100 p-0 tab-pane" id="examples" role="tabpanel" aria-labelledby="examples-tab"> + <table id="unmatched-examples" class="table table-sm table-hover"> + <thead> + <tr> + <th scope="col">{% trans "Przykład" %}</th> + <th scope="col">{% trans "Źródło" %}</th> + <th scope="col">{% trans "Opinia" %}</th> + </tr> + </thead> + <tbody id="unmatched-examples-list"> + </tbody> + </table> + <p class="mx-1 my-1"id="unmatched-no-examples">{% trans "Brak przykładów" %}</p> + </div> +</div> diff --git a/entries/templates/unification_frames.html b/entries/templates/unification_frames.html index 13993106703887723b6acfbe636200c826346e89..d6d8313485d401a9d424b6192223cae8021f0355 100644 --- a/entries/templates/unification_frames.html +++ b/entries/templates/unification_frames.html @@ -5,12 +5,27 @@ {% block title %}{% trans "Hasła" %}{% endblock %} + +{% block styles %} +<!-- for autocomplete --> +<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"> +<!-- https://datatables.net/ --> +<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.22/sc-2.0.3/datatables.min.css"/> +<!--link rel="stylesheet" type="text/css" href="{% static 'entries/css/panels.css' %}"--> +<link rel="stylesheet" type="text/css" href="{% static 'entries/css/entries.css' %}"> +<link rel="stylesheet" type="text/css" href="{% static 'entries/css/unification_frames.css' %}"> +<link rel="stylesheet" type="text/css" href="{% static 'common/css/role_colours.css' %}"> +<link rel="stylesheet" href="{% static 'entries/css/jquery-impromptu.min.css' %}" type="text/css" media="screen" charset="utf-8" /> +{% endblock %} + {% block scripts %} {{ block.super }} <script src="{% static 'entries/js/unification.js' %}"></script> <script src="{% static 'entries/js/unification_frames_list.js' %}"></script> + <script src="{% static 'entries/js/selectional_preference.js' %}"></script> + <script src="{% static 'entries/js/jquery-impromptu.min.js' %}"></script> {% endblock %} {% block left_pane %}{% include "unification_frames_list.html" %}{% endblock %} -{% block right_pane %}{% include "unified_frame_edit_display.html" %}{% endblock %} +{% block right_pane %}{% include "unification_edit_display.html" %}{% endblock %} diff --git a/entries/templates/unified_frame_edit_display.html b/entries/templates/unified_frame_edit_display.html deleted file mode 100644 index ccd8c6965070efb6735f9658de15c7bc1085d4e8..0000000000000000000000000000000000000000 --- a/entries/templates/unified_frame_edit_display.html +++ /dev/null @@ -1,72 +0,0 @@ -{% load i18n %} - -<div class="tab-content h-100 w-100 p-0" id="entryTabsContent"> - <div class="col h-100 w-100 p-0 tab-pane show active" id="semantics" role="tabpanel" aria-labelledby="semantics-tab"> - - <div class="row m-0 p-0 overflow-auto"> - <div class="tab-content h-300 w-100 p-0" id="unified-frame-content"> - <div class="col h-100 w-100 p-0 tab-pane show active" id="unified-frame-content-col" role="tabpanel" aria-labelledby="semantics-tab"> - <div class="row m-0 p-0"> - <button type="button" onclick="addSelectivePreference(frame_content[0], 1)" id="add_preference">Dodaj preferencje (przykład użycia - do wstawienia w odpowiednie miejsce)</button> - </div> - <div class="row m-0 p-0" id="semantics-top-pane-1"> - <div id="unified-frame"></div> - </div> - <div class="row m-0 p-0" id="semantics-top-pane-2"> - <div id="unified-frame-lexical-units"></div> - </div> - <div class="row m-0 p-0" id="semantics-top-pane-3"> - <div id="semantics-frames"></div> - </div> - </div> - </div> - </div> - <div class="row m-0 p-0 overflow-auto" id="semantics-examples-pane"> - <table id="semantics-examples" class="table table-sm table-hover"> - <thead> - <tr> - <th scope="col">{% trans "Przykład" %}<i id="examples-argument"></i><i id="examples-lu"></i><i id="examples-schema"></i></th> - <th scope="col">{% trans "Źródło" %}</th> - <th scope="col">{% trans "Opinia" %}</th> - </tr> - </thead> - <tbody id="semantics-examples-list"> - </tbody> - </table> - <p class="mx-1 my-1"id="semantics-no-examples">{% trans "Brak przykładów" %}</p> - </div> - </div> - <div class="col h-100 w-100 p-0 tab-pane" id="syntax" role="tabpanel" aria-labelledby="syntax-tab"> - <div class="col w-100 px-1 pt-0 pb-0 overflow-auto" id="syntax-schemata-pane"> - <div id="syntax-schemata"></div> - </div> - <div class="col w-100 p-0 overflow-auto" id="syntax-examples-pane"> - <table id="syntax-examples" class="table table-sm table-hover"> - <thead> - <tr> - <th scope="col">{% trans "Przykład" %}</th> - <th scope="col">{% trans "Źródło" %}</th> - <th scope="col">{% trans "Opinia" %}</th> - </tr> - </thead> - <tbody id="syntax-examples-list"> - </tbody> - </table> - <p class="mx-1 my-1"id="syntax-no-examples">{% trans "Brak przykładów" %}</p> - </div> - </div> - <div class="col h-100 w-100 p-0 tab-pane" id="examples" role="tabpanel" aria-labelledby="examples-tab"> - <table id="unmatched-examples" class="table table-sm table-hover"> - <thead> - <tr> - <th scope="col">{% trans "Przykład" %}</th> - <th scope="col">{% trans "Źródło" %}</th> - <th scope="col">{% trans "Opinia" %}</th> - </tr> - </thead> - <tbody id="unmatched-examples-list"> - </tbody> - </table> - <p class="mx-1 my-1"id="unmatched-no-examples">{% trans "Brak przykładów" %}</p> - </div> -</div> diff --git a/entries/views.py b/entries/views.py index 3336070b401ffd66e42e2206495cae315e65611b..bd41a844fbdef104ffbd6d82409eb64fe4f44078 100644 --- a/entries/views.py +++ b/entries/views.py @@ -539,7 +539,7 @@ def frame2dict(frame, entry_meanings): return { 'opinion' : FRAME_OPINION()[frame.opinion.key], 'opinion_key' : frame.opinion.key, - 'id' : str(frame.id), + 'id' : frame.id, 'lexical_units' : [ { 'str' : lu.text_rep, @@ -553,6 +553,7 @@ def frame2dict(frame, entry_meanings): 'arguments' : [ { 'str' : str(a), + 'argument_id' : a.id, 'id' : '{}-{}'.format(frame.id, a.id), 'role' : '{}{}'.format(a.role.role.role.lower(), ' ' + a.role.attribute.attribute.lower() if a.role.attribute else ''), 'preferences' : get_prefs_list(a), diff --git a/unifier/models.py b/unifier/models.py index 25e7914814f7a38e22220fa66da2cf9e62c6539e..fc2d74a20ad8b57d6ebf0ddd1ece8a3f2b5900fe 100644 --- a/unifier/models.py +++ b/unifier/models.py @@ -49,7 +49,7 @@ class UnifiedRelationalSelectionalPreference(models.Model): class UnifiedFrame2SlowalFrameMapping(models.Model): unified_frame = models.ForeignKey(UnifiedFrame, related_name='unified_frame_2_slowal_frame', on_delete=models.PROTECT) - slowal_frame = models.ForeignKey(Frame, related_name='slowal_frame_2_unified_frame', on_delete=models.PROTECT) + slowal_frame = models.OneToOneField(Frame, related_name='slowal_frame_2_unified_frame', on_delete=models.PROTECT) class UnifiedFrameArgumentSlowalFrameMapping(models.Model): unified_agrument = models.ForeignKey(UnifiedFrameArgument, related_name='unified_agrument_mapping', on_delete=models.PROTECT) diff --git a/unifier/views.py b/unifier/views.py index 370a1ea4a4d892dc64b4a4aef58eda06230892e5..a114f106e47631c7313b783f439743ad878d923b 100644 --- a/unifier/views.py +++ b/unifier/views.py @@ -86,13 +86,13 @@ def get_unified_frames(request): def unifiedFrame2dict(frame): return { - 'id' : str(frame.id), - 'title' : str(frame.title), + 'id' : frame.id, + 'title' : frame.title, 'status' : str(frame.status), 'arguments' : [ { 'str' : str(a), - 'id' : '{}-{}'.format(frame.id, a.id), + 'id' : a.id, 'role' : '{}{}'.format(a.role.role.role.lower(), ' ' + a.role.attribute.attribute.lower() if a.role.attribute else '') if a.role is not None else None, 'role_type' : a.role_type.type.lower(), 'preferences' : get_prefs_list(a), @@ -107,8 +107,8 @@ def unifiedFrame2dict(frame): 'slowal_frame_id': slowal_frame_mapping.slowal_frame.id, 'slowal_frame_argument_mapping': [ { - 'unified_frame_agrument.id': slowal_frame_arg_mapping.unified_agrument.id, - 'slowal_frame_agrument.id': slowal_frame_arg_mapping.slowal_agrument.id, + 'unified_frame_agrument_id': slowal_frame_arg_mapping.unified_agrument.id, + 'slowal_frame_agrument_id': slowal_frame_arg_mapping.slowal_agrument.id, } for slowal_frame_arg_mapping in slowal_frame_mapping.unified_frame_argument_mapping.all() ] } for slowal_frame_mapping in frame.unified_frame_2_slowal_frame.all()