From 966a057a08d550a22bb151b3cf5bce16bbe86e94 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Wed, 11 Sep 2024 09:38:08 -0400 Subject: [PATCH] feat: allow panphon 0.21 where possible And make the unit test accept 0.21 and older versions. Fixes #388 --- g2p/tests/test_fallback.py | 24 ++++++++++++++---------- pyproject.toml | 4 +++- requirements.txt | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/g2p/tests/test_fallback.py b/g2p/tests/test_fallback.py index ae7b184f..bc25c27e 100755 --- a/g2p/tests/test_fallback.py +++ b/g2p/tests/test_fallback.py @@ -72,16 +72,20 @@ def test_mapping(self): ], ) test_ipa = align_to_dummy_fallback(ipa_mapping, "out", quiet=True) - self.assertEqual( - test_ipa.rules, - [ - Rule(rule_input="æ", rule_output="ɑ", match_pattern="æ"), - Rule(rule_input="ɐ", rule_output="ɑ", match_pattern="ɐ"), - Rule(rule_input="ɑ̃", rule_output="ɑ", match_pattern="ɑ̃"), - Rule(rule_input="β", rule_output="s", match_pattern="β"), - Rule(rule_input="ɡ", rule_output="t", match_pattern="ɡ"), - ], - ) + panphon_021_ref = [ + Rule(rule_input="æ", rule_output="ɑ", match_pattern="æ"), + Rule(rule_input="ɐ", rule_output="i", match_pattern="ɐ"), + Rule(rule_input="ɑ̃", rule_output="ɑ", match_pattern="ɑ̃"), + Rule(rule_input="β", rule_output="s", match_pattern="β"), + Rule(rule_input="ɡ", rule_output="t", match_pattern="ɡ"), + ] + panphon_020_ref = [ + panphon_021_ref[0], + Rule(rule_input="ɐ", rule_output="ɑ", match_pattern="ɐ"), + *panphon_021_ref[2:], + ] + if test_ipa.rules != panphon_021_ref: + self.assertEqual(test_ipa.rules, panphon_020_ref) if __name__ == "__main__": diff --git a/pyproject.toml b/pyproject.toml index 024b682c..dde03ef5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,9 @@ dependencies = [ "coloredlogs>=15.0.1", "networkx>=2.6", "openpyxl", - "panphon>=0.19,<0.21", + "panphon>=0.19", + "panphon<0.21; python_version<'3.9'", + "panphon<0.21; platform_system=='Windows'", "pydantic>=2.4", "pyyaml>=5.2", "regex", diff --git a/requirements.txt b/requirements.txt index efef4bde..ecf1bd62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -63,7 +63,7 @@ openpyxl==3.1.2 # via hatch.envs.prod packaging==24.0 # via gunicorn -panphon==0.20.0 +panphon==0.21.2 # via hatch.envs.prod pydantic==2.6.4 # via