Repository: bst-mug/acres

Issue:
[Filtering] Expansion should not contain another acronym
E.g. ACC => "ACI und ACE" has been provided by the n-gram model, but not filtered out.

Discussion:

Patch:
diff --git a/acres/rater/full.py b/acres/rater/full.py
index 0d03352..f9421dd 100644
--- a/acres/rater/full.py
+++ b/acres/rater/full.py
@@ -1,6 +1,7 @@
 """
 Rating submodule for full form checks.
 """
+from acres.util import acronym as acro_util
 from acres.util import functions
 
 
@@ -55,6 +56,19 @@ def _has_capitals(full: str) -> bool:
     return True
 
 
+def _contain_acronym(full: str) -> bool:
+    """
+
+    :param full:
+    :return:
+    """
+    words = full.split()
+    for word in words:
+        if acro_util.is_acronym(word):
+            return True
+    return False
+
+
 def _compute_full_valid(full: str) -> int:
     """
     [For internal use only] Compute all checks on full forms.
@@ -77,6 +91,9 @@ def _compute_full_valid(full: str) -> int:
     if not _has_capitals(full):
         ret += 8
 
+    if _contain_acronym(full):
+        ret += 16
+
     return ret
 
 


Test patch:
diff --git a/tests/rater/test_full.py b/tests/rater/test_full.py
index 55a18aa..eeb713a 100644
--- a/tests/rater/test_full.py
+++ b/tests/rater/test_full.py
@@ -1,6 +1,16 @@
 from acres.rater import full
 
 
+def test__contain_acronym():
+    # Baseline
+    assert not full._contain_acronym("Elektrokardiogramm")
+    assert full._contain_acronym("VSM Bypass")
+    assert full._contain_acronym("Gamma GT")
+
+    # Only acronym
+    assert full._contain_acronym("EKG")
+
+
 def test__compute_full_valid():
     # Full form has parenthesis
     assert 1 == full._compute_full_valid("Abcde(fghi")
@@ -12,4 +22,7 @@ def test__compute_full_valid():
     assert 4 == full._compute_full_valid("Auf das")
 
     # Full form has no capitals
-    assert 8 == full._compute_full_valid("ambulanz")
\ No newline at end of file
+    assert 8 == full._compute_full_valid("ambulanz")
+
+    # Full form has no capitals
+    assert 16 == full._compute_full_valid("VSM Bypass")