Skip to content
Snippets Groups Projects
Commit 18d5b3da authored by Vriezen, E.C. (Emma)'s avatar Vriezen, E.C. (Emma)
Browse files

Added the mistake_finder.py (forgot in last commit). Used for filtering out...

Added the mistake_finder.py (forgot in last commit). Used for filtering out the mistakes. Skeleton now. Integrated its call in statistics.py for the Anchor Algorithm (commented out now). Small PEP8 change in anchor_algorithm.py.
parent cf135e9e
No related branches found
No related tags found
1 merge request!44Emmas edits to master
......@@ -39,8 +39,8 @@ class AnchorAlgorithm(AlignmentStrategy):
if src_last_anchor < src_index:
shd_index = self._shadow.index(word.anchor)
self._search_between_anchors(src_last_anchor,
shd_last_anchor, src_index,
shd_index)
shd_last_anchor, src_index,
shd_index)
shd_last_anchor = self._shadow.index(word.anchor) + 1
src_last_anchor = src_index + 1
......
from mistake_enum import Mistake
# TODO: Finish this skeleton.
class MistakeFinder:
"""Finds the mistakes in already aligned lists of Words"""
@staticmethod
def start(self, source, shadow):
"""Find all the mistakes and classify them."""
# Loop over the shadow:
for index, word in enumerate(shadow):
if not self._check_repetition(word, index): # If not a repetition,
if not self._check_semantic_mistake(word): # semantic,
if not self._check_phonentic_mistake(word): # or phonetic,
# ... then shadow word is random:
word.mistake = Mistake.RANDOM
# Loop over the source:
for word in source:
if not word.shadowed and word.mistake is None:
# If not yet marked as mistake, then it is skipped:
word.mistake = Mistake.SKIPPED
# def _check_repetition(self, word, index):
#
# TODO: WordNet integration. Function below should be usable already!
# def _check_semantic_mistake(self, shd_word):
# shd_string = shd_word.word
# src_string = shd_word.source.word
# if model.seman_check.semantically_related(src_string, shd_string):
# shd_word.mistake = Mistake.SEMANTIC
# src_word.mistake = Mistake.SEMANTIC
# return True
# return False
# def _check_phonetic_mistake(self, shd_word):
#
from saa_algorithm import SaaAlgorithm
from saa_Romeo import SaaRomeo
from anchor_algorithm import AnchorAlgorithm
from mistake_finder import MistakeFinder
class Statistics:
......@@ -27,7 +28,7 @@ class Statistics:
shadow: the words in the shadow file
"""
#Alignment 0
# Alignment 0
print('Romeo')
self._strategy = SaaRomeo()
source_align, shadow_align = self._strategy.align(source, shadow)
......@@ -51,6 +52,8 @@ class Statistics:
if s_word.has_source():
print(f'source: {s_word.source} shadow: {s_word}')
correctness = self._strategy.correctly_shadowed(source)
# TODO: Make the mistake finding work with the statement below
# MistakeFinder.start(source_align_em, shadow_align_em)
return source_align, shadow_align, correctness
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment