diff --git a/frontend/src/components/unification/free_lu/FreeLuEdit.vue b/frontend/src/components/unification/free_lu/FreeLuEdit.vue index 353915c4a79707bdc6c228428f4016e651367efa..20fd2249c752756d82361c0cf858aa5f311b976e 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 2070e51ecef47a657b5d91631bb78f6bf05fdcb4..93d48b67f4ad73592eef05c120e4db2aef31f87f 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))