From f45b5608cc369119ae036868ee7d10e0bc24f6d1 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Sat, 20 Jul 2024 05:16:46 +0800 Subject: [PATCH] Test 0.2.3 --- .github/workflows/python-test.yml | 7 +++++-- tests/test_tojyutping.py | 16 ---------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 801cbf1..e3b7e41 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -14,10 +14,10 @@ jobs: version: ['3.8', '3.10', '3.x'] runs-on: ${{ matrix.os }} steps: - - name: Checkout 0.3.0 + - name: Checkout 0.2.3 uses: actions/checkout@v4 with: - ref: '0.3.0' + ref: '0.2.3' fetch-depth: 0 fetch-tags: true - name: Checkout latest commit @@ -26,6 +26,7 @@ jobs: path: latest - shell: bash run: | + rm -rf tests cp -r latest/tests tests/ rm -rf latest - name: Set up Python @@ -35,6 +36,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install opencc pygtrie + python preprocess.py pip install pytest pytest-subtests - name: Run tests run: | diff --git a/tests/test_tojyutping.py b/tests/test_tojyutping.py index a7c15f3..f5a8e33 100644 --- a/tests/test_tojyutping.py +++ b/tests/test_tojyutping.py @@ -30,11 +30,6 @@ def test_get_jyutping_text(self): expected = "gam3 ngaam1 lou5 sai3 jiu1 kau4 keoi5 dang2 zan6 jiu3 hoi1 wui2, zing6 dai1 ge3 je5 ngo5 wui5 gaau2 dim6 gaa3 laa3." self.assertEqual(result, expected) - def test_get_jyutping_candidates(self): - result = ToJyutping.get_jyutping_candidates(self.test_string) - expected = [('咁', ['gam3', 'gam2', 'gam1', 'gam4']), ('啱', ['ngaam1', 'aam1', 'am1', 'ngam1']), ('老', ['lou5', 'lou2']), ('世', ['sai3', 'sai2']), ('要', ['jiu1', 'jiu3', 'jiu2']), ('求', ['kau4']), ('佢', ['keoi5', 'heoi5']), ('等', ['dang2']), ('陣', ['zan6', 'zan2']), ('要', ['jiu3', 'jiu2', 'jiu1']), ('開', ['hoi1']), ('會', ['wui2', 'wui5', 'wui6', 'wui3', 'kui2', 'kui3', 'kwui2']), (',', []), ('剩', ['zing6', 'sing6']), ('低', ['dai1']), ('嘅', ['ge3', 'ge2', 'koi2', 'koi3']), ('嘢', ['je5', 'e5']), ('我', ['ngo5', 'o5']), ('會', ['wui5', 'wui6', 'wui2', 'wui3', 'kui2', 'kui3', 'kwui2']), ('搞', ['gaau2']), ('掂', ['dim6', 'dim3', 'dim1']), ('㗎', ['gaa3', 'ga3', 'gaa2', 'gaa1', 'gaa4']), ('喇', ['laa3', 'laa1', 'laak3', 'laa5', 'laat3']), ('。', [])] - self.assertEqual(result, expected) - def test_get_ipa_list(self): result = ToJyutping.get_ipa_list(self.test_string) expected = [('咁', 'kɐm˧'), ('啱', 'ŋaːm˥'), ('老', 'lou̯˩˧'), ('世', 'sɐi̯˧'), ('要', 'jiːu̯˥'), ('求', 'kʰɐu̯˨˩'), ('佢', 'kʰɵy̑˩˧'), ('等', 'tɐŋ˧˥'), ('陣', 't͡sɐn˨'), ('要', 'jiːu̯˧'), ('開', 'hɔːi̯˥'), ('會', 'wuːi̯˧˥'), (',', None), ('剩', 't͡seŋ˨'), ('低', 'tɐi̯˥'), ('嘅', 'kɛː˧'), ('嘢', 'jɛː˩˧'), ('我', 'ŋɔː˩˧'), ('會', 'wuːi̯˩˧'), ('搞', 'kaːu̯˧˥'), ('掂', 'tiːm˨'), ('㗎', 'kaː˧'), ('喇', 'laː˧'), ('。', None)] @@ -50,11 +45,6 @@ def test_get_ipa_text(self): expected = 'kɐm˧.ŋaːm˥.lou̯˩˧.sɐi̯˧.jiːu̯˥.kʰɐu̯˨˩.kʰɵy̑˩˧.tɐŋ˧˥.t͡sɐn˨.jiːu̯˧.hɔːi̯˥.wuːi̯˧˥ | t͡seŋ˨.tɐi̯˥.kɛː˧.jɛː˩˧.ŋɔː˩˧.wuːi̯˩˧.kaːu̯˧˥.tiːm˨.kaː˧.laː˧' self.assertEqual(result, expected) - def test_get_ipa_candidates(self): - result = ToJyutping.get_ipa_candidates(self.test_string) - expected = [('咁', ['kɐm˧', 'kɐm˧˥', 'kɐm˥', 'kɐm˨˩']), ('啱', ['ŋaːm˥', 'aːm˥', 'ɐm˥', 'ŋɐm˥']), ('老', ['lou̯˩˧', 'lou̯˧˥']), ('世', ['sɐi̯˧', 'sɐi̯˧˥']), ('要', ['jiːu̯˥', 'jiːu̯˧', 'jiːu̯˧˥']), ('求', ['kʰɐu̯˨˩']), ('佢', ['kʰɵy̑˩˧', 'hɵy̑˩˧']), ('等', ['tɐŋ˧˥']), ('陣', ['t͡sɐn˨', 't͡sɐn˧˥']), ('要', ['jiːu̯˧', 'jiːu̯˧˥', 'jiːu̯˥']), ('開', ['hɔːi̯˥']), ('會', ['wuːi̯˧˥', 'wuːi̯˩˧', 'wuːi̯˨', 'wuːi̯˧', 'kʰuːi̯˧˥', 'kʰuːi̯˧', 'kʷʰuːi̯˧˥']), (',', []), ('剩', ['t͡seŋ˨', 'seŋ˨']), ('低', ['tɐi̯˥']), ('嘅', ['kɛː˧', 'kɛː˧˥', 'kʰɔːi̯˧˥', 'kʰɔːi̯˧']), ('嘢', ['jɛː˩˧', 'ɛː˩˧']), ('我', ['ŋɔː˩˧', 'ɔː˩˧']), ('會', ['wuːi̯˩˧', 'wuːi̯˨', 'wuːi̯˧˥', 'wuːi̯˧', 'kʰuːi̯˧˥', 'kʰuːi̯˧', 'kʷʰuːi̯˧˥']), ('搞', ['kaːu̯˧˥']), ('掂', ['tiːm˨', 'tiːm˧', 'tiːm˥']), ('㗎', ['kaː˧', 'kɐ˧', 'kaː˧˥', 'kaː˥', 'kaː˨˩']), ('喇', ['laː˧', 'laː˥', 'laːk̚˧', 'laː˩˧', 'laːt̚˧']), ('。', [])] - self.assertEqual(result, expected) - def test_jyutping2ipa(self): result = ToJyutping.jyutping2ipa("cin1 ngaa5") expected = "t͡sʰiːn˥.ŋaː˩˧" @@ -100,9 +90,6 @@ def test_get_jyutping_performance(self): def test_get_jyutping_text_performance(self): self.performance_test(lambda: ToJyutping.get_jyutping_text(self.test_string)) - def test_get_jyutping_candidates_performance(self): - self.performance_test(lambda: ToJyutping.get_jyutping_candidates(self.test_string), expected_time=30) - def test_get_ipa_list_performance(self): self.performance_test(lambda: ToJyutping.get_ipa_list(self.test_string)) @@ -112,8 +99,5 @@ def test_get_ipa_performance(self): def test_get_ipa_text_performance(self): self.performance_test(lambda: ToJyutping.get_ipa_text(self.test_string)) - def test_get_ipa_candidates_performance(self): - self.performance_test(lambda: ToJyutping.get_ipa_candidates(self.test_string), expected_time=30) - if __name__ == '__main__': unittest.main(verbosity=2)