diff --git a/dictionary/saving.py b/dictionary/saving.py index 057bf12..8a5a0df 100644 --- a/dictionary/saving.py +++ b/dictionary/saving.py @@ -9,7 +9,13 @@ from wordnet.models import LexicalUnit def get_semantic_operations(lemma, schemata_conversions): connections = [] operations = [] + # frames = lemma.entry_obj.actual_frames() + frames = lemma.entry_obj.actual_frames() + for entry in lemma.entry_obj.rel_entries.all(): + new_frames = entry.actual_frames() + frames |= new_frames + for conv in schemata_conversions: schema_operations = get_reconnect_operations_and_extend_connections(frames, connections, diff --git a/semantics/views.py b/semantics/views.py index ac551c0..0b913f3 100644 --- a/semantics/views.py +++ b/semantics/views.py @@ -225,6 +225,8 @@ def create_frames_context(lemma_id, user): else: lemma_info = {"include": False} frame_display["frames"].append({"frame_id": str(frame.id), "colspan": str(max(len(frame_roles), 1)), "rowspan": str(frame_preferences_rowspan), "status": status, "display": display, "lemma": lemma_info}) + + schemata_ids = [f.id for f in lemma.frames.all()] for complement, complement_class in zip(frame_complements, frame_ids): if complement_class not in complement_arguments: @@ -232,29 +234,40 @@ def create_frames_context(lemma_id, user): for schema_position in complement.realizations.all(): schema = schema_position.frame - position = schema_position.position - argument = schema_position.argument - alternation = schema_position.alternation - realization_id = u'schema_' + str(schema.id) + u'_pos_' + str(position.id) + '_arg_' + str(argument.id) + '_' + 'alt_' + str(alternation) + '_' - complement_arguments[complement_class].append(realization_id) - if realization_id not in arguments_frame_connected: - arguments_frame_connected[realization_id] = [] - arguments_frame_connected[realization_id].append('frame_' + str(frame.id) + '_') - if schema.id in alternations[frame.id]: - alternations[frame.id][schema.id] = max(alternations[frame.id][schema.id], alternation) - else: - alternations[frame.id][schema.id] = alternation - # alternations[frame.id] = {} + if schema.id in schemata_ids: + position = schema_position.position + argument = schema_position.argument + alternation = schema_position.alternation + realization_id = u'schema_' + str(schema.id) + u'_pos_' + str(position.id) + '_arg_' + str(argument.id) + '_' + 'alt_' + str(alternation) + '_' + complement_arguments[complement_class].append(realization_id) + if realization_id not in arguments_frame_connected: + arguments_frame_connected[realization_id] = [] + arguments_frame_connected[realization_id].append('frame_' + str(frame.id) + '_') + if schema.id in alternations[frame.id]: + alternations[frame.id][schema.id] = max(alternations[frame.id][schema.id], alternation) + else: + alternations[frame.id][schema.id] = alternation + # alternations[frame.id] = {} frames_display.append(frame_display) # ala["ma"] = "kot" + + frames_count_local = 0 + frames_count_imported = 0 + for frame in frames_display: + if frame['visible']: + if frame['local']: + frames_count_local += 1 + else: + frames_count_imported += 1 + frames_count = str(frames_count_local) + "+" + str(frames_count_imported) context = { 'frames_display': frames_display, 'connections': {'connected': complement_arguments, 'connected_reverse': arguments_frame_connected}, - 'frames_count': lemma.entry_obj.actual_frames().count(), + 'frames_count': frames_count, 'alternations': alternations }