From 6b4e32c76f0bcb8957d251b6aeeba1480ba6005c Mon Sep 17 00:00:00 2001 From: Romeo <r.haak@student.ru.nl> Date: Mon, 16 Dec 2019 11:10:51 +0100 Subject: [PATCH] Revised the analyze method as all of the information could now be retrieved from the wrapper class. --- umbra/statistics.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/umbra/statistics.py b/umbra/statistics.py index 5cb05191..c27b0d94 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 -- GitLab