diff --git a/ovos_workshop/skills/ovos.py b/ovos_workshop/skills/ovos.py index 00e4053..af2c61b 100644 --- a/ovos_workshop/skills/ovos.py +++ b/ovos_workshop/skills/ovos.py @@ -2607,7 +2607,11 @@ def _join_word_list_es(items: List[str], connector: str, sep: str = ",") -> str: joined_string = items[0] # Check for euphonic transformation cases for "y" - if cons[connector] == "y" and items[-1][0].lower() == "i": + w = items[-1].lower().lstrip("h")[0] + if cons[connector] == "y" and w in ["i", "í"]: final_connector = "e" + # Check for euphonic transformation cases for "o" + if cons[connector] == "o" and w in ["o", "ó"]: + final_connector = "u" return f"{joined_string} {final_connector} {items[-1]}" diff --git a/test/unittests/test_euphony.py b/test/unittests/test_euphony.py index 2cade93..2e9d09d 100644 --- a/test/unittests/test_euphony.py +++ b/test/unittests/test_euphony.py @@ -42,6 +42,16 @@ def test_single_word(self): result = _join_word_list_it(["mare"], "and") self.assertEqual(result, "mare") + def test_multiple_euphonic_transformations(self): + # Test multiple 'ed' transformations in the same list + result = _join_word_list_it(["casa", "estate", "inverno", "autunno"], "and") + self.assertEqual(result, "casa, estate, inverno e autunno") + + def test_mixed_conjunctions(self): + # Test combining 'and' and 'or' conjunctions + result = _join_word_list_it(["mare", "oceano", "isola"], "or") + self.assertEqual(result, "mare, oceano o isola") + class TestJoinWordListEs(unittest.TestCase): @@ -49,6 +59,17 @@ def test_euphonic_conjunction_and(self): # Test euphonic transformation from "y" to "e" result = _join_word_list_es(["Juan", "Irene"], "and") self.assertEqual(result, "Juan e Irene") + result = _join_word_list_es(["vaqueros", "indios"], "and") + self.assertEqual(result, "vaqueros e indios") + result = _join_word_list_es(["Manuel", "Hilario"], "and") + self.assertEqual(result, "Manuel e Hilario") + + def test_euphonic_conjunction_or(self): + # Test euphonic transformation from "o" to "u" + result = _join_word_list_es(["Manuel", "Óscar"], "or") + self.assertEqual(result, "Manuel u Óscar") + result = _join_word_list_es(["unos", "otros"], "or") + self.assertEqual(result, "unos u otros") if __name__ == "__main__":