Skip to content

Commit

Permalink
Merge pull request #7 from patriotyk/main
Browse files Browse the repository at this point in the history
Tests pipeline and first tests for vowels
  • Loading branch information
dchaplinsky authored Dec 29, 2023
2 parents 21ab40f + 6b71fa0 commit cde2c54
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 ipa_uk --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ipa_uk --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
2 changes: 1 addition & 1 deletion ipa_uk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AccentIsMissing(ValueError):
pass


def ipa(text: str, check_accent: bool) -> str:
def ipa(text: str, check_accent: bool = False) -> str:
"""
Returns the IPA transcription of the given word or sentence according to the Wiktionary algorithm
Expand Down
103 changes: 103 additions & 0 deletions tests/test_phonemizations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
from ipa_uk import ipa, ACUTE

def test_stressed_a():
assert ipa(f"ма{ACUTE}ма") == "ˈmɑmɐ"

def test_unstressed_a():
assert ipa(f"мо{ACUTE}ва") == "ˈmɔu̯ɐ"

def test_stressed_e():
assert ipa(f"ве{ACUTE}лич") == "ˈʋɛlet͡ʃ"

def test_unstressed_e():
assert ipa(f"Пе{ACUTE}тре") == "ˈpɛtre"

def test_stressed_y():
assert ipa(f"при{ACUTE}мха") == "ˈprɪmxɐ"

def test_unstressed_y():
assert ipa(f"мине{ACUTE}") == "meˈnɛ"

def test_stressed_i():
assert ipa(f"ві{ACUTE}ра") == "ˈʋʲirɐ"

def test_unstressed_i():
assert ipa(f"ко{ACUTE}рінь") == "ˈkɔrʲinʲ"

def test_stressed_o():
assert ipa(f"коро{ACUTE}ва") == "kɔˈrɔu̯ɐ"

def test_unstressed_o():
assert ipa(f"о{ACUTE}сінь") == "ˈɔsʲinʲ"

def test_stressed_u():
assert ipa(f"У{ACUTE}мань") == "ˈumɐnʲ"

def test_unstressed_u():
assert ipa(f"туди{ACUTE}") == "tʊˈdɪ"

# assert ipa("тому") == "tomu"



# assert ipa("пил") == "pɪl"
# assert ipa("піт") == "pʲit"
# assert ipa("бук") == "buk"
# assert ipa("біль") == "bʲilʲ"
# assert ipa("мат") == "mɑt"
# assert ipa("стать") == "stɑtʲ"
# assert ipa("дим") == "dɪm"
# assert ipa("дім") == "dʲim"
# assert ipa("кут") == "kut"
# assert ipa("кіт") == "kʲit"
# assert ipa("ґуля") == "gulʲɐ"
# assert ipa("ґіпс") == "gʲips"
# assert ipa("глум") == "ɦlum"
# assert ipa("гість") == "ɦʲisʲtʲ"
# assert ipa("хор") == "xɔr"
# assert ipa("хід") == "xʲid"
# assert ipa("фах") == "fɑx"
# assert ipa("фільм") == "fʲilʲm"
# assert ipa("вир") == "ʋɪr"
# assert ipa("він") == "ʋʲin"
# assert ipa("вухо") == "wuxo"
# assert ipa("враз") == "wrɑz"
# assert ipa("вперше") == "ʍpɛrʃe"
# assert ipa("сад") == "sɑd"
# assert ipa("Сян") == "sʲɐn" # alternative ɕɐn
# assert ipa("зад") == "zɑd"
# assert ipa("зір") == "zʲir" # alternative ʑir
# assert ipa("шар") == "ʃɑr"
# assert ipa("шість") == "ʃʲisʲtʲ"
# assert ipa("затишшя") == "zɐtɪʃʲ:ɐ"
# assert ipa("жар") == "ʒɑr"
# assert ipa("жінка") == "ʒʲinkɐ"
# assert ipa("заміжжя") == "zɐmiʒʲ:ɐ"
# assert ipa("цирк") == "ʦɪrk"
# assert ipa("ціна") == "ʦʲinɑ"
# assert ipa("дзень") == "ʣɛnʲ"
# assert ipa("дзінь") == "ʣʲinʲ"
# assert ipa("час") == "ʧɑs"
# assert ipa("чіп") == "ʧʲip"
# assert ipa("узбіччя") == "ʊzbʲiʧʲ:ɐ"
# assert ipa("бджола") == "bdʒolɑ"
# assert ipa("бджіл") == "bdʒʲil"
# assert ipa("мат") == "mɑt"
# assert ipa("міра") == "mʲirɐ"
# assert ipa("нас") == "nɑs"
# assert ipa("ніс") == "nʲis"
# assert ipa("лук") == "luk"
# assert ipa("люк") == "lʲʊk"
# assert ipa("рак") == "rɑk"
# assert ipa("ряд") == "rʲɐd"
# assert ipa("як") == "jɐk"
# assert ipa("гай") == "ɦɑi̯"
# assert ipa("найшов") == "nɐi̯ʃɔu̯"
# assert ipa("став") == "stɑu̯"

# assert ipa("Полісся") == "polʲisʲ:ɐ"
# assert ipa("чужоземець") == "ˌt͡ʃʊʒozɛmet͡sʲ"




0 comments on commit cde2c54

Please sign in to comment.