diff --git a/umbra/needleman_wunsch.py b/umbra/needleman_wunsch.py index ddc27a4953fdb9863792b62e5b41b19888fa9f5d..6a6d5ac45b2dc017af162058b03202a2bdbbb418 100644 --- a/umbra/needleman_wunsch.py +++ b/umbra/needleman_wunsch.py @@ -3,14 +3,13 @@ from alignment_strategy import AlignmentStrategy from words import Sentence import numpy as np from mistake_enum import Mistake -from dutch_mmetaphone import DutchPhonetics class NeedlemanWunsch(AlignmentStrategy): """Class that aligns the words of a shadow and source file according to the Needleman-Wunsch algorithm""" - def __init__(self, seman_checker, form_checker): + def __init__(self, seman_checker, form_checker, phon_checker): super().__init__() self._match = 4 self._mismatch = -2 @@ -25,10 +24,11 @@ class NeedlemanWunsch(AlignmentStrategy): self._matrix = None self._seman_checker = seman_checker self._form_checker = form_checker + self._phon_checker = phon_checker def alignment_options(self, match=None, mismatch=None, - gap_sc=None, seman_match=None, repetition=None, - form_match=None): + gap_sc=None, seman_match=None, phon_match=None, + repetition=None, form_match=None): """ Set the scores that are allocated whilst aligning. Can be changed one at a time or more at once. @@ -115,7 +115,7 @@ class NeedlemanWunsch(AlignmentStrategy): elif self._seman_checker.semantically_related( source_word.word, shadow_word.word): value = self._seman_match - elif DutchPhonetics.compare(source_word.word, + elif self._phon_checker.compare(source_word.word, shadow_word.word): value = self._phon_match else: @@ -212,7 +212,7 @@ class NeedlemanWunsch(AlignmentStrategy): source.shadow = shadow source.mistake = Mistake.FORM shadow.mistake = Mistake.FORM - elif DutchPhonetics.compare(source.word, shadow.word): + elif self._phon_checker.compare(source.word, shadow.word): source.shadowed = True source.mistake = Mistake.PHONETIC shadow.mistake = Mistake.PHONETIC