diff --git a/umbra/statistics.py b/umbra/statistics.py index 5cb0519106ebc9f4369fb9eb1a5709f8efbdd531..c27b0d949922caa304c34e88683a5db99ad8871b 100644 --- a/umbra/statistics.py +++ b/umbra/statistics.py @@ -4,6 +4,7 @@ from anchor_algorithm import AnchorAlgorithm from mistake_finder import MistakeFinder from semantic_checker import SemanticChecker from form_checker import FormChecker +from mistake_counter import MistakeCounter from utils import Utils as ut import time @@ -24,6 +25,7 @@ class Statistics: self._seman_checker = SemanticChecker() self._form_checker = FormChecker() self._mistake_finder = MistakeFinder(self._seman_checker) + self._mistake_counter = MistakeCounter() @property def strategy(self): @@ -33,15 +35,19 @@ class Statistics: def strategy(self, strategy): self._strategy = strategy - def analyze(self, source, shadow): + def analyze(self, trial): """Perform the necessary analyses. Currently uses all strategies for testing purposes. Should only use the specified strategy upon release. Args: - source: the words in the source file - shadow: the words in the shadow file + trial: the trial to analyze + + Returns: + correctness """ + source = trial.source + shadow = trial.shadow # Make a deepcopy such that the testing is equal for both strategies: source_em = copy.deepcopy(source) @@ -77,4 +83,8 @@ class Statistics: discrete_time = time.time() - discrete_start_time results += f'taken time:{discrete_time}\n' + # Now the results are from the Anchor algorithm analysis. + trial.results = self._mistake_counter.\ + calculate_accuracy(source_em, shadow_em) + return correctness