Commit 76f54edc7f482c1d1c73189b480682a8f3597530

Authored by Bartłomiej Nitoń
2 parents 50977ac3 22d47dcb

Merge branch 'dev' into bartek

dictionary/saving.py
@@ -9,7 +9,13 @@ from wordnet.models import LexicalUnit @@ -9,7 +9,13 @@ from wordnet.models import LexicalUnit
9 def get_semantic_operations(lemma, schemata_conversions): 9 def get_semantic_operations(lemma, schemata_conversions):
10 connections = [] 10 connections = []
11 operations = [] 11 operations = []
  12 + # frames = lemma.entry_obj.actual_frames()
  13 +
12 frames = lemma.entry_obj.actual_frames() 14 frames = lemma.entry_obj.actual_frames()
  15 + for entry in lemma.entry_obj.rel_entries.all():
  16 + new_frames = entry.actual_frames()
  17 + frames |= new_frames
  18 +
13 for conv in schemata_conversions: 19 for conv in schemata_conversions:
14 schema_operations = get_reconnect_operations_and_extend_connections(frames, 20 schema_operations = get_reconnect_operations_and_extend_connections(frames,
15 connections, 21 connections,
semantics/views.py
@@ -225,6 +225,8 @@ def create_frames_context(lemma_id, user): @@ -225,6 +225,8 @@ def create_frames_context(lemma_id, user):
225 else: 225 else:
226 lemma_info = {"include": False} 226 lemma_info = {"include": False}
227 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}) 227 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})
  228 +
  229 + schemata_ids = [f.id for f in lemma.frames.all()]
228 230
229 for complement, complement_class in zip(frame_complements, frame_ids): 231 for complement, complement_class in zip(frame_complements, frame_ids):
230 if complement_class not in complement_arguments: 232 if complement_class not in complement_arguments:
@@ -232,29 +234,40 @@ def create_frames_context(lemma_id, user): @@ -232,29 +234,40 @@ def create_frames_context(lemma_id, user):
232 234
233 for schema_position in complement.realizations.all(): 235 for schema_position in complement.realizations.all():
234 schema = schema_position.frame 236 schema = schema_position.frame
235 - position = schema_position.position  
236 - argument = schema_position.argument  
237 - alternation = schema_position.alternation  
238 - realization_id = u'schema_' + str(schema.id) + u'_pos_' + str(position.id) + '_arg_' + str(argument.id) + '_' + 'alt_' + str(alternation) + '_'  
239 - complement_arguments[complement_class].append(realization_id)  
240 - if realization_id not in arguments_frame_connected:  
241 - arguments_frame_connected[realization_id] = []  
242 - arguments_frame_connected[realization_id].append('frame_' + str(frame.id) + '_')  
243 - if schema.id in alternations[frame.id]:  
244 - alternations[frame.id][schema.id] = max(alternations[frame.id][schema.id], alternation)  
245 - else:  
246 - alternations[frame.id][schema.id] = alternation  
247 - # alternations[frame.id] = {} 237 + if schema.id in schemata_ids:
  238 + position = schema_position.position
  239 + argument = schema_position.argument
  240 + alternation = schema_position.alternation
  241 + realization_id = u'schema_' + str(schema.id) + u'_pos_' + str(position.id) + '_arg_' + str(argument.id) + '_' + 'alt_' + str(alternation) + '_'
  242 + complement_arguments[complement_class].append(realization_id)
  243 + if realization_id not in arguments_frame_connected:
  244 + arguments_frame_connected[realization_id] = []
  245 + arguments_frame_connected[realization_id].append('frame_' + str(frame.id) + '_')
  246 + if schema.id in alternations[frame.id]:
  247 + alternations[frame.id][schema.id] = max(alternations[frame.id][schema.id], alternation)
  248 + else:
  249 + alternations[frame.id][schema.id] = alternation
  250 + # alternations[frame.id] = {}
248 251
249 252
250 frames_display.append(frame_display) 253 frames_display.append(frame_display)
251 254
252 # ala["ma"] = "kot" 255 # ala["ma"] = "kot"
  256 +
  257 + frames_count_local = 0
  258 + frames_count_imported = 0
  259 + for frame in frames_display:
  260 + if frame['visible']:
  261 + if frame['local']:
  262 + frames_count_local += 1
  263 + else:
  264 + frames_count_imported += 1
  265 + frames_count = str(frames_count_local) + "+" + str(frames_count_imported)
253 266
254 context = { 267 context = {
255 'frames_display': frames_display, 268 'frames_display': frames_display,
256 'connections': {'connected': complement_arguments, 'connected_reverse': arguments_frame_connected}, 269 'connections': {'connected': complement_arguments, 'connected_reverse': arguments_frame_connected},
257 - 'frames_count': lemma.entry_obj.actual_frames().count(), 270 + 'frames_count': frames_count,
258 'alternations': alternations 271 'alternations': alternations
259 } 272 }
260 273