From 3352a6d86ba309eb4c316e19c03b40c61650f27b Mon Sep 17 00:00:00 2001 From: "Verbeek, J.M. (Janneke)" <j.verbeek@student.ru.nl> Date: Sun, 1 Dec 2019 17:19:44 +0100 Subject: [PATCH] Now matches source and shadow based on identifying no. --- umbra/anchor_algorithm.py | 3 +-- umbra/controller.py | 1 + umbra/model.py | 12 +++++++----- umbra/utils.py | 7 +++++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/umbra/anchor_algorithm.py b/umbra/anchor_algorithm.py index 14c8d314..2c2c0c98 100644 --- a/umbra/anchor_algorithm.py +++ b/umbra/anchor_algorithm.py @@ -52,8 +52,7 @@ class AnchorAlgorithm(AlignmentStrategy): for src_index in range(src_start, src_end): src_word = self._source[src_index] if not src_word.is_anchor(): - self._search_word_in_interval(src_word, shd_start, shd_end, - source, shadow) + self._search_word_in_interval(src_word, shd_start, shd_end) else: # If src_word is an anchor, only search in shadow after it: shd_start = self._shadow.index(src_word.anchor()) diff --git a/umbra/controller.py b/umbra/controller.py index dfaded87..942c83da 100644 --- a/umbra/controller.py +++ b/umbra/controller.py @@ -126,5 +126,6 @@ class Controller: data = self._filereader.read() if type == "source": self._model._data_source = data + self._model._id = ut.id_regex(path) else: self._model._data_shadow = data diff --git a/umbra/model.py b/umbra/model.py index 0fec6e7c..ab1705a3 100644 --- a/umbra/model.py +++ b/umbra/model.py @@ -11,6 +11,7 @@ class Model: self._analysis_results = None self._multi_results = {} self._save_pref = None + self._id = -1 @property def save_pref(self): @@ -67,11 +68,12 @@ class Model: print(self._multi_data_shadow, self.has_shadow()) if self._multi_data_shadow: for key, data in self._multi_data_shadow.items(): - # TODO: if same number then do this - result = self._stats.analyze(self._data_source, data) - self.add_to_dict(key+"_res", result, self._multi_results) - - # else pass + if self._id in key: + result = self._stats.analyze(self._data_source, data) + self.add_to_dict(key+"_res", result, self._multi_results) + else: + print("passed") + pass else: self._analysis_results = \ self._stats.analyze(self._data_source, self._data_shadow) diff --git a/umbra/utils.py b/umbra/utils.py index 964a1794..4d169ab1 100644 --- a/umbra/utils.py +++ b/umbra/utils.py @@ -40,3 +40,10 @@ class Utils: match = re.search("AO\d", path) if match: return match.group() + + def id_regex(path): + match = re.search("\d\.TextGrid", path) + # Make sure that not different number accidentally + if match: + return match.group()[0] + -- GitLab