Repository: ualbertaaltlab/morphodict
Issue: ESPT Does not recognize certain actors (e.g. "I") or goals

When doing an espt search, phrases such as "I see you" or "I have" are not recognized as phrases and therefore not inflected. Known examples include (please add more in the comments):

"I have"
https://itwewina.altlab.app/search?q=I+have+espt%3A1

"I see you"
https://itwewina.altlab.app/search?q=I+see+you+espt%3A1

"I speak Cree"
https://itwewina.altlab.app/search?q=I%20speak%20Cree%20espt%3A1

Changed files:
src/CreeDictionary/API/search/test_espt.py, src/CreeDictionary/API/search/espt.py, src/CreeDictionary/API/search/test_espt_crk.py

diff --git a/src/CreeDictionary/API/search/espt.py b/src/CreeDictionary/API/search/espt.py
index fd4b6f5d..303148e7 100644
--- a/src/CreeDictionary/API/search/espt.py
+++ b/src/CreeDictionary/API/search/espt.py
@@ -69,8 +69,8 @@ class EsptSearch:
                 self.search_run.add_verbose_message(espt_analysis_error=repr(e))
                 return
 
-        self.search_run.query.replace_query(analyzed_query.filtered_query)
-        self.query_analyzed_ok = True
+            self.search_run.query.replace_query(analyzed_query.filtered_query)
+            self.query_analyzed_ok = True
 
         self.search_run.add_verbose_message(
             filtered_query=analyzed_query.filtered_query,
diff --git a/src/CreeDictionary/API/search/test_espt.py b/src/CreeDictionary/API/search/test_espt.py
deleted file mode 100644
index 02e3d351..00000000
--- a/src/CreeDictionary/API/search/test_espt.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import pytest
-
-from CreeDictionary.API.search.espt import PhraseAnalyzedQuery
-
-
-@pytest.mark.parametrize(
-    ("query", "has_tags", "tags", "filtered_query"),
-    [
-        ("atim", False, None, None),
-        ("they swam", True, ["+V", "+AI", "+Prt", "+3Pl"], "swim"),
-        ("dog +Px1Sg+Sg", False, None, None),
-    ],
-)
-def test_search_with_tags(query, has_tags, tags, filtered_query):
-    result = PhraseAnalyzedQuery(query)
-    assert result.has_tags == has_tags
-    if has_tags:
-        assert result.tags == tags
-        assert result.filtered_query == filtered_query
diff --git a/src/CreeDictionary/API/search/test_espt_crk.py b/src/CreeDictionary/API/search/test_espt_crk.py
index 00a7044d..dab6729a 100644
--- a/src/CreeDictionary/API/search/test_espt_crk.py
+++ b/src/CreeDictionary/API/search/test_espt_crk.py
@@ -2,10 +2,26 @@ import pytest
 
 from CreeDictionary.API.models import Wordform
 from CreeDictionary.API.search.core import SearchRun
-from CreeDictionary.API.search.espt import EsptSearch
+from CreeDictionary.API.search.espt import EsptSearch, PhraseAnalyzedQuery
 from CreeDictionary.API.search.types import Result
 
 
+@pytest.mark.parametrize(
+    ("query", "has_tags", "tags", "filtered_query"),
+    [
+        ("atim", False, None, None),
+        ("they swam", True, ["+V", "+AI", "+Prt", "+3Pl"], "swim"),
+        ("dog +Px1Sg+Sg", False, None, None),
+    ],
+)
+def test_search_with_tags(query, has_tags, tags, filtered_query):
+    result = PhraseAnalyzedQuery(query)
+    assert result.has_tags == has_tags
+    if has_tags:
+        assert result.tags == tags
+        assert result.filtered_query == filtered_query
+
+
 @pytest.mark.parametrize(
     ("search", "params"),
     [
@@ -45,6 +61,16 @@ from CreeDictionary.API.search.types import Result
                 "expected_inflection": "wâpiwak",
             },
         ],
+        [
+            "bear",
+            {
+                # Don’t try to inflect results for searches not analyzable as phrases
+                "expected_query_terms": ["bear"],
+                "expected_new_tags": [],
+                "lemma": "maskwa",
+                "expected_inflection": "maskwa",
+            },
+        ],
     ],
 )
 def test_espt_search(db, search, params):