From 695fd05e868afca41ca20cb2d3c94317a8e23238 Mon Sep 17 00:00:00 2001
From: dcz <dcz@ipipan.waw.pl>
Date: Wed, 24 Apr 2024 14:30:56 +0200
Subject: [PATCH] Show lu examples bugfix.
---
.../unification/free_lu/FreeLuEdit.vue | 2 +
unifier/views.py | 70 +++++++++++--------
2 files changed, 42 insertions(+), 30 deletions(-)
diff --git a/frontend/src/components/unification/free_lu/FreeLuEdit.vue b/frontend/src/components/unification/free_lu/FreeLuEdit.vue
index 353915c..20fd224 100644
--- a/frontend/src/components/unification/free_lu/FreeLuEdit.vue
+++ b/frontend/src/components/unification/free_lu/FreeLuEdit.vue
@@ -155,6 +155,7 @@
if (this.active_slowal_frame === frame) {
this.active_slowal_frame = null;
} else {
+ this.selectedLus = null;
this.active_slowal_frame = frame;
}
},
@@ -633,6 +634,7 @@
(response) => {
alert(gettext("Rama została oznaczona jako gotowa."));
show_info('Rama została oznaczona jako gotowa.');
+ this.selectedLus = null;
this.loadEntry();
$.prompt.close();
},
diff --git a/unifier/views.py b/unifier/views.py
index 2070e51..93d48b6 100644
--- a/unifier/views.py
+++ b/unifier/views.py
@@ -353,43 +353,53 @@ def unified_frame_2_dict(frame):
def get_examples(frames):
examples = []
for frame in frames:
+ for lu in frame.lexical_units.all():
+ for connection in lu.example_connections.all():
+ elem = extract_example(connection)
+ if elem not in examples:
+ examples.append(elem)
for argument in frame.arguments.all():
for connection in argument.example_connections.all():
- example = connection.example
- frame_ids, argument_ids, lu_ids = set(), set(), set()
- schema_ids, phrases, phrases_syntax = set(), set(), set()
- positions = set()
- for example_connection in example.example_connections.all():
- for conn_argument in example_connection.arguments.all():
- frame_ids.add(conn_argument.frame.id)
- argument_ids.add('{}-{}'.format(conn_argument.frame.id, conn_argument.id))
- if example_connection.lexical_unit:
- lu_ids.add(example_connection.lexical_unit.id)
- for hook in example_connection.schema_connections.all():
- schema_ids.add(hook.schema.id)
- phrases.add('{}-{}-{}-{}'.format(hook.schema.id, hook.position.id, hook.phrase_type.id,
- hook.alternation - 1))
- phrases_syntax.add('{}-{}-{}'.format(hook.schema.id, hook.position.id, hook.phrase_type.id))
- positions.add('{}-{}'.format(hook.schema.id, hook.position.id))
- elem = {
- 'id': str(example.id),
- 'sentence': example.sentence,
- 'source': EXAMPLE_SOURCE()[example.source.key],
- 'opinion': EXAMPLE_OPINION()[example.opinion.key],
- 'note': example.note,
- 'frame_ids': sorted(frame_ids),
- 'argument_ids': sorted(argument_ids),
- 'lu_ids': sorted(lu_ids),
- 'schema_ids': sorted(schema_ids),
- 'phrases': sorted(phrases),
- 'phrases_syntax': sorted(phrases_syntax),
- 'positions': sorted(positions),
- }
+ elem = extract_example(connection)
if elem not in examples:
examples.append(elem)
return sorted(examples, key=lambda x: x['sentence'])
+def extract_example(connection):
+ example = connection.example
+ frame_ids, argument_ids, lu_ids = set(), set(), set()
+ schema_ids, phrases, phrases_syntax = set(), set(), set()
+ positions = set()
+ for example_connection in example.example_connections.all():
+ for conn_argument in example_connection.arguments.all():
+ frame_ids.add(conn_argument.frame.id)
+ argument_ids.add('{}-{}'.format(conn_argument.frame.id, conn_argument.id))
+ if example_connection.lexical_unit:
+ lu_ids.add(example_connection.lexical_unit.id)
+ for hook in example_connection.schema_connections.all():
+ schema_ids.add(hook.schema.id)
+ phrases.add('{}-{}-{}-{}'.format(hook.schema.id, hook.position.id, hook.phrase_type.id,
+ hook.alternation - 1))
+ phrases_syntax.add('{}-{}-{}'.format(hook.schema.id, hook.position.id, hook.phrase_type.id))
+ positions.add('{}-{}'.format(hook.schema.id, hook.position.id))
+ elem = {
+ 'id': str(example.id),
+ 'sentence': example.sentence,
+ 'source': EXAMPLE_SOURCE()[example.source.key],
+ 'opinion': EXAMPLE_OPINION()[example.opinion.key],
+ 'note': example.note,
+ 'frame_ids': sorted(frame_ids),
+ 'argument_ids': sorted(argument_ids),
+ 'lu_ids': sorted(lu_ids),
+ 'schema_ids': sorted(schema_ids),
+ 'phrases': sorted(phrases),
+ 'phrases_syntax': sorted(phrases_syntax),
+ 'positions': sorted(positions),
+ }
+ return elem
+
+
def to_lemma(lexical_units):
return ", ".join(map(lambda l: l['str'], lexical_units))
--
GitLab