From 3bbc73a5bd6c88763dea0ea8ec5a311c8842994f Mon Sep 17 00:00:00 2001
From: "Vriezen, E.C. (Emma)" <e.vriezen@student.ru.nl>
Date: Mon, 16 Dec 2019 12:42:32 +0100
Subject: [PATCH] Shadow words are now also marked as a phonetic mistake if
 they are marked as such.

---
 umbra/mistake_finder.py | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/umbra/mistake_finder.py b/umbra/mistake_finder.py
index ec48f96f..90ac984d 100644
--- a/umbra/mistake_finder.py
+++ b/umbra/mistake_finder.py
@@ -83,11 +83,12 @@ class MistakeFinder:
                 not phonetic_mistake and src_index < (
                 len(self._source) - 1):  # Crude fix, but removes error
             src_word = self._source[src_index]
-            if DutchPhonetics.compare(src_word.word, shd_word.word):
+            phonetic_mistake = self.phonetically_related(src_word, shd_word)
+            if phonetic_mistake:
                 shd_word.mistake = Mistake.PHONETIC
+                shd_word.source = src_word
                 if not src_word.shadowed and src_word.mistake is None:
                     src_word.mistake = Mistake.PHONETIC
-                phonetic_mistake = True
             src_index += 1
         return phonetic_mistake
 
@@ -213,6 +214,22 @@ class MistakeFinder:
             and shd_string != src_string
         return related
 
+    def phonetically_related(self, src_word, shd_word):
+        """Checks if src_word and shd_word are phonetically related.
+
+        Args:
+            src_word: SourceWord instance
+            shd_word: ShadowWord instance
+        Returns:
+            related: True if src_word and shd_word are phonetically related,
+            False if not.
+        """
+        shd_string = shd_word.word
+        src_string = src_word.word
+        related = DutchPhonetics.compare(src_string, shd_string)\
+            and shd_string != src_string
+        return related
+
     def form_related(self, src_word, shd_word):
         """Checks if src_word and shd_word are related in form.
 
-- 
GitLab