diff --git a/semantics/management/commands/frame_compare_0.py b/semantics/management/commands/frame_compare_0.py index cf2f871..986e255 100644 --- a/semantics/management/commands/frame_compare_0.py +++ b/semantics/management/commands/frame_compare_0.py @@ -25,21 +25,25 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - - print len(frames) + print " ...done" # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() diff --git a/semantics/management/commands/frame_compare_1.py b/semantics/management/commands/frame_compare_1.py index 9a6808f..986e255 100644 --- a/semantics/management/commands/frame_compare_1.py +++ b/semantics/management/commands/frame_compare_1.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 1 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_10.py b/semantics/management/commands/frame_compare_10.py index 28c65e2..986e255 100644 --- a/semantics/management/commands/frame_compare_10.py +++ b/semantics/management/commands/frame_compare_10.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 10 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_11.py b/semantics/management/commands/frame_compare_11.py index 75e8125..986e255 100644 --- a/semantics/management/commands/frame_compare_11.py +++ b/semantics/management/commands/frame_compare_11.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 11 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_12.py b/semantics/management/commands/frame_compare_12.py index e51d4f5..986e255 100644 --- a/semantics/management/commands/frame_compare_12.py +++ b/semantics/management/commands/frame_compare_12.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 12 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_13.py b/semantics/management/commands/frame_compare_13.py index fbb8bfb..986e255 100644 --- a/semantics/management/commands/frame_compare_13.py +++ b/semantics/management/commands/frame_compare_13.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 13 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_14.py b/semantics/management/commands/frame_compare_14.py index 5cde5ab..986e255 100644 --- a/semantics/management/commands/frame_compare_14.py +++ b/semantics/management/commands/frame_compare_14.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 14 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_15.py b/semantics/management/commands/frame_compare_15.py index cb7f241..986e255 100644 --- a/semantics/management/commands/frame_compare_15.py +++ b/semantics/management/commands/frame_compare_15.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 15 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_2.py b/semantics/management/commands/frame_compare_2.py index 755959b..986e255 100644 --- a/semantics/management/commands/frame_compare_2.py +++ b/semantics/management/commands/frame_compare_2.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 2 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_3.py b/semantics/management/commands/frame_compare_3.py index 4b4dbda..986e255 100644 --- a/semantics/management/commands/frame_compare_3.py +++ b/semantics/management/commands/frame_compare_3.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 3 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_4.py b/semantics/management/commands/frame_compare_4.py index 8ecd164..986e255 100644 --- a/semantics/management/commands/frame_compare_4.py +++ b/semantics/management/commands/frame_compare_4.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 4 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_5.py b/semantics/management/commands/frame_compare_5.py index 853c558..986e255 100644 --- a/semantics/management/commands/frame_compare_5.py +++ b/semantics/management/commands/frame_compare_5.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 5 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_6.py b/semantics/management/commands/frame_compare_6.py index 5e2d414..986e255 100644 --- a/semantics/management/commands/frame_compare_6.py +++ b/semantics/management/commands/frame_compare_6.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 6 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_7.py b/semantics/management/commands/frame_compare_7.py index cd9f691..986e255 100644 --- a/semantics/management/commands/frame_compare_7.py +++ b/semantics/management/commands/frame_compare_7.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 7 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_8.py b/semantics/management/commands/frame_compare_8.py index 91b854c..986e255 100644 --- a/semantics/management/commands/frame_compare_8.py +++ b/semantics/management/commands/frame_compare_8.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 8 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_9.py b/semantics/management/commands/frame_compare_9.py index 6a5d30d..986e255 100644 --- a/semantics/management/commands/frame_compare_9.py +++ b/semantics/management/commands/frame_compare_9.py @@ -17,7 +17,7 @@ from settings import PROJECT_PATH BUNDLE_SIZE = 50 PROCESSES_NO = 16 -PROCESS_ID = 9 +PROCESS_ID = 0 class Command(BaseCommand): args = 'none' @@ -25,20 +25,26 @@ class Command(BaseCommand): def handle(self, **options): # SPLIT FRAMES IN BUNLES + print "splitting frames in bundles..." frames = SemanticFrame.objects.filter(next=None, removed=False, entry__isnull=False).order_by('id') frame_bundles = [] frame_bundle = [] i = 0 # frame_bundle size for frame in frames: - frame_bundle.append(frame) - i += 1 - if i == BUNDLE_SIZE: - frame_bundles.append(frame_bundle) - frame_bundle = [] - i = 0 + if frame.entry.actual_lemma().status.priority >= 90: # (S)ready / (S)validated + lus = frame.lexical_units.all() + if len(lus) > 0 and\ + max([lu.luid for lu in lus]) >=0: + frame_bundle.append(frame) + i += 1 + if i == BUNDLE_SIZE: + frame_bundles.append(frame_bundle) + frame_bundle = [] + i = 0 if i != 0: frame_bundles.append(frame_bundle) - + print " ...done" + # LOCAL DATABASE CONNECTION session, TT_dict = get_db_data() LexicalUnit._session = session @@ -54,13 +60,13 @@ class Command(BaseCommand): f = Frame.from_slowal(frame) frames1.append(f) if i == j: - match_frames_diagonal(frames1, session, TT_dict) # , verbose=True, fake=True) + match_frames_diagonal(frames1, session, TT_dict)# , verbose=True, fake=True) else: frames2 = [] for frame in frame_bundles[j]: f = Frame.from_slowal(frame) frames2.append(f) - match_frames(frames1, frames2, session, TT_dict) # , verbose=True, fake=True) + match_frames(frames1, frames2, session, TT_dict)# , verbose=True, fake=True) c += 1 diff --git a/semantics/management/commands/frame_compare_modules/match_frames.py b/semantics/management/commands/frame_compare_modules/match_frames.py index def8477..d365223 100644 --- a/semantics/management/commands/frame_compare_modules/match_frames.py +++ b/semantics/management/commands/frame_compare_modules/match_frames.py @@ -36,6 +36,15 @@ cut_value[u'Attribute'] = -np.log(0.8) cut_value[u'Measure'] = -np.log(0.8) cut_value[u'Lemma'] = -np.log(1.0) +arg_rank = defaultdict(lambda: 0) +arg_rank[u'Time'] = 1 +arg_rank[u'Location'] = 1 +arg_rank[u'Path'] = 1 +arg_rank[u'Attribute'] = 1 +arg_rank[u'Measure'] = 1 +arg_rank[u'Lemma'] = 1 + + def find_max_arg_matching_value(label, arglist1, arglist2, selprefs_table): s1 = len(arglist1) s2 = len(arglist2) @@ -47,13 +56,14 @@ def find_max_arg_matching_value(label, arglist1, arglist2, selprefs_table): cut = s2 ans_pos = hungarian_algorithm(array.copy()) result = 0 + missing = [0, 0, 0] for i, j in ans_pos: # i and j are matched if i < cut: result += array[i][j] else: - result += cut_value[label] - return result + missing[arg_rank[label]] += 1 + return result, tuple(missing) def match_undefined_preferences_and_max_match_the_rest(label, arglist1, arglist2, selprefs_table): selprefs1 = copy(arglist1) @@ -74,18 +84,35 @@ def match_undefined_preferences_and_max_match_the_rest(label, arglist1, arglist2 del selprefs2[j] # i and j are matched if len(selprefs1) == 0 and len(selprefs2) == 0: - return 1.0 + return 1.0, (0, 0, 0) else: return find_max_arg_matching_value(label, selprefs1, selprefs2, selprefs_table) - - + + +misses_coefficient = defaultdict(lambda: -np.log(0.1)) +misses_coefficient[0.0] = -np.log(1.0) +misses_coefficient[1.0/3] = -np.log(0.99) +misses_coefficient[2.0/3] = -np.log(0.97) +misses_coefficient[1.0] = -np.log(0.95) +misses_coefficient[4.0/3] = -np.log(0.92) +misses_coefficient[5.0/3] = -np.log(0.9) +misses_coefficient[2.0] = -np.log(0.5) + def find_matching_value(frame1, frame2, selprefs_table): labels = set(frame1.get_role_labels()) | set(frame2.get_role_labels()) tmp = 0 + missing0 = 0 + missing1 = 0 + missing2 = 0 for label in sorted(labels): - # tmp += find_max_arg_matching_value(label, frame1.get_arguments(label), frame2.get_arguments(label), selprefs_table) - tmp += match_undefined_preferences_and_max_match_the_rest(label, frame1.get_arguments(label), frame2.get_arguments(label), selprefs_table) - return np.exp(-tmp) + val, (m0, m1, m2) = match_undefined_preferences_and_max_match_the_rest(label, frame1.get_arguments(label), frame2.get_arguments(label), selprefs_table) + tmp += val + missing0 += m0 + missing1 += m1 + missing2 += m2 + m = missing0 + (missing1 * 1.0) / 3 + res = tmp + misses_coefficient[m] + return np.exp(-res) def match_transformed_frames(frame1, frame2, rule, selprefs_table): v = find_matching_value(frame1, frame2, selprefs_table)