Skip to content

Commit

Permalink
Test 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
graphemecluster committed Jul 19, 2024
1 parent 09f7d88 commit f45b560
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand Down
16 changes: 0 additions & 16 deletions tests/test_tojyutping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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ː˩˧"
Expand Down Expand Up @@ -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))

Expand All @@ -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)

0 comments on commit f45b560

Please sign in to comment.