-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deal with 'o', double 'u' #3
Open
AnastasiaKuliak
wants to merge
2
commits into
main
Choose a base branch
from
nastia-tweaks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−6
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,8 @@ def ipa(text: str, check_accent: bool) -> str: | |
r"([йклмнпрстфхцчшщ])\1": r"\1ː", | ||
r"дждж": r"джː", | ||
r"дздз": r"дзː", | ||
# double vowels: | ||
r"уу": r"уː", | ||
} | ||
|
||
phonetic: str = text | ||
|
@@ -153,7 +155,7 @@ def ipa(text: str, check_accent: bool) -> str: | |
# including stress mark for single-syllable words if check_accent is set to true | ||
number_of_vowels = len(re.findall(r"[ɑɛiɪuɔ]", phonetic)) | ||
if number_of_vowels == 1 and check_accent: | ||
phonetic = re.sub(r"([ɑɛiɪuɔ])", r"ˈ\1", phonetic) | ||
phonetic = re.sub(r"([ɑɛiɪuo])", r"ˈ\1", phonetic) | ||
|
||
# palatalizable consonants before /i/ or /j/ become palatalized | ||
phonetic = re.sub(r"(" + palatalizable + ")([ː]?)([ˈ]?)i", r"\1ʲ\2\3i", phonetic) | ||
|
@@ -222,11 +224,12 @@ def ipa(text: str, check_accent: bool) -> str: | |
# unstressed /ɑ/ has an allophone [ɐ] | ||
phonetic = re.sub(r"([^ˈ])ɑ", r"\1ɐ", phonetic) | ||
phonetic = re.sub(r"^ɑ", r"ɐ", phonetic) | ||
# unstressed /u/ has an allophone [ʊ] | ||
phonetic = re.sub(r"([^ˈ])u", r"\1ʊ", phonetic) | ||
phonetic = re.sub(r"^u", r"ʊ", phonetic) | ||
# unstressed /ɔ/ has a stressed allophone [o] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I believe the comment should say stressed /ɔ/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yeah, you're right |
||
phonetic = re.sub(r"(ˈ)ɔ", r"\1o", phonetic) | ||
# unstressed /ɔ/ has by assimilation an allophone [o] before a stressed syllable with /u/ or /i/ | ||
phonetic = re.sub(r"ɔ([bdzʒɡɦmnlrpftskxʲʃ͡]+)ˈ([uiʊ]+)", r"o\1ˈ\2", phonetic) | ||
# unstressed /u/ has an allophone [ʊ] | ||
phonetic = re.sub(r"([^ˈ])u", r"\1ʊ", phonetic) | ||
# one allophone [e] covers unstressed /ɛ/ and /ɪ/ | ||
phonetic = re.sub(r"([^ˈ])ɛ", r"\1e", phonetic) | ||
phonetic = re.sub(r"^ɛ", r"e", phonetic) | ||
|
@@ -261,5 +264,9 @@ def ipa(text: str, check_accent: bool) -> str: | |
|
||
|
||
if __name__ == "__main__": | ||
for w in [f"Сла{ACUTE}ва", f"Украї{ACUTE}ні", f"сме{ACUTE}рть", f"ворога{ACUTE}м"]: | ||
print(w, "->", ipa(w, check_accent=True)) | ||
for w in [f"Сла{ACUTE}ва", f"Украї{ACUTE}ні", f"сме{ACUTE}рть", f"ворога{ACUTE}м", | ||
# подвійний "у" | ||
f"ва{ACUTE}куум", | ||
# "o" | ||
f"при{ACUTE}пхнутого", f"поверхово{ACUTE}див", f"електро{ACUTE}нні"]: | ||
print(w, "->", ipa(w, check_accent=True)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two lines above we are counting vowels and using this list of characters: ɑɛiɪuɔ
And here we are using o instead of ɔ. As far as I can understand from the code, there is no chance, that the word at this point of the processing will have any o's, as they are unconditionally replaced with ɔ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to rewrite this. We need to add 'o' to the 'number_of_vowels' because otherwise stressing of 'o's works pretty randomly.