Skip to content
Snippets Groups Projects
Commit 695fd05e authored by dcz's avatar dcz
Browse files

Show lu examples bugfix.

parent 3e9f236b
Branches
No related merge requests found
......@@ -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();
},
......
......@@ -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))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment