Skip to content

Commit

Permalink
es support
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 12, 2024
1 parent 1472b26 commit 747f3b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
21 changes: 21 additions & 0 deletions test/unittests/test_euphony.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,34 @@ 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):

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__":
Expand Down

0 comments on commit 747f3b4

Please sign in to comment.