Skip to content
Snippets Groups Projects
Commit e18768cf authored by Valk, T.J. de (Thijme)'s avatar Valk, T.J. de (Thijme)
Browse files

Added an empty form_checker class that still needs to be implemented. Added...

Added an empty form_checker class that still needs to be implemented. Added the mistake type form to the mistake enum. Added the checks from the form_checker to the NW class.
parent 176c16d4
No related branches found
No related tags found
No related merge requests found
class FormChecker:
def __init__(self):
pass
def form_related(self, source_word, shadow_word):
pass
\ No newline at end of file
...@@ -16,3 +16,4 @@ class Mistake(Enum): ...@@ -16,3 +16,4 @@ class Mistake(Enum):
SEMANTIC = "semantic" SEMANTIC = "semantic"
SKIPPED = "skipped" # For source words that are not shadowed SKIPPED = "skipped" # For source words that are not shadowed
RANDOM = "random" # For shadow words that do not reflect a source word RANDOM = "random" # For shadow words that do not reflect a source word
FORM = "form" # For verbs that are shadowed in another form
...@@ -16,6 +16,7 @@ class NeedlemanWunsch(AlignmentStrategy): ...@@ -16,6 +16,7 @@ class NeedlemanWunsch(AlignmentStrategy):
self._gap_sc = -1 self._gap_sc = -1
self._seman_match = 2 self._seman_match = 2
self._repetition = 0 self._repetition = 0
self._form_match = 2
self._pointers = ['diag', 'up', 'left'] self._pointers = ['diag', 'up', 'left']
self._source = None self._source = None
self._shadow = None self._shadow = None
...@@ -23,7 +24,8 @@ class NeedlemanWunsch(AlignmentStrategy): ...@@ -23,7 +24,8 @@ class NeedlemanWunsch(AlignmentStrategy):
self._seman_checker = seman_checker self._seman_checker = seman_checker
def alignment_options(self, match=None, mismatch=None, def alignment_options(self, match=None, mismatch=None,
gap_sc=None, seman_match=None, repetition=None): gap_sc=None, seman_match=None, repetition=None,
form_match=None):
""" Set the scores that are allocated whilst aligning. Can be changed """ Set the scores that are allocated whilst aligning. Can be changed
one at a time or more at once. one at a time or more at once.
...@@ -44,6 +46,10 @@ class NeedlemanWunsch(AlignmentStrategy): ...@@ -44,6 +46,10 @@ class NeedlemanWunsch(AlignmentStrategy):
self._gap_sc = gap_sc self._gap_sc = gap_sc
if seman_match: if seman_match:
self._seman_match = seman_match self._seman_match = seman_match
if repetition:
self._repetition = repetition
if form_match:
self._form_match = form_match
def align(self, source, shadow): def align(self, source, shadow):
""" This is the main function of finding alignments. """ This is the main function of finding alignments.
...@@ -93,6 +99,9 @@ class NeedlemanWunsch(AlignmentStrategy): ...@@ -93,6 +99,9 @@ class NeedlemanWunsch(AlignmentStrategy):
for j in range(1, n+1): for j in range(1, n+1):
if self._source[j - 1] == self._shadow[i - 1]: if self._source[j - 1] == self._shadow[i - 1]:
value = self._match value = self._match
elif self._form_checker.form_related(self._source[j-1].word,
self._shadow[i-1].word):
value = self._form_match
elif self._seman_checker.semantically_related( elif self._seman_checker.semantically_related(
self._source[j-1].word, self._shadow[i-1].word): self._source[j-1].word, self._shadow[i-1].word):
value = self._seman_match value = self._seman_match
...@@ -174,4 +183,8 @@ class NeedlemanWunsch(AlignmentStrategy): ...@@ -174,4 +183,8 @@ class NeedlemanWunsch(AlignmentStrategy):
source.shadowed = True source.shadowed = True
source.mistake = Mistake.SEMANTIC source.mistake = Mistake.SEMANTIC
shadow.mistake = Mistake.SEMANTIC shadow.mistake = Mistake.SEMANTIC
elif self._form_checker.form_related(source.word, shadow.word):
source.shadowed = True
source.mistake = Mistake.FORM
shadow.mistake = Mistake.FORM
return source, shadow return source, shadow
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