-
-
Notifications
You must be signed in to change notification settings - Fork 629
Fix to_finals dropping the 'n' from syllabic 'ng' (嗯/呣/唔) in non-strict mode #371
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -288,6 +288,18 @@ def test_to_initials(pinyin, strict, result): | |
|
|
||
| ['gui', True, False, 'uei'], | ||
| ['gui', False, False, 'ui'], | ||
|
|
||
| # 嗯/呣/唔 等鼻音节:非严格模式下整个 m/n/ng 作为韵母, | ||
| # 严格模式下没有韵母(保持原有设计)。 | ||
|
Comment on lines
+292
to
+293
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. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Normalize the punctuation in the added test comments. Lines 292-293 and Line 300 contain fullwidth punctuation that Ruff flags as Also applies to: 300-300 🧰 Tools🪛 Ruff (0.15.20)[warning] 292-292: Comment contains ambiguous (RUF003) [warning] 292-292: Comment contains ambiguous (RUF003) [warning] 293-293: Comment contains ambiguous (RUF003) [warning] 293-293: Comment contains ambiguous (RUF003) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| ['ńg', False, False, 'ng'], | ||
| ['ňg', False, False, 'ng'], | ||
| ['ǹg', False, False, 'ng'], | ||
| ['ng', False, False, 'ng'], | ||
| ['ńg', True, False, ''], | ||
| ['ng', True, False, ''], | ||
| # 控制项:单独的 m/n 行为保持不变。 | ||
| ['ń', False, False, 'n'], | ||
| ['ḿ', False, False, 'm'], | ||
| ]) | ||
| def test_to_finals(pinyin, strict, v_to_u, result): | ||
| assert to_finals(pinyin, strict=strict, v_to_u=v_to_u) == result | ||
|
|
@@ -301,6 +313,9 @@ def test_to_finals(pinyin, strict, v_to_u, result): | |
| ['yū', True, 'ǖ'], | ||
| ['yu1', True, 'ǖ'], | ||
| ['yū', False, 'ū'], | ||
|
|
||
| ['ńg', False, 'ńg'], | ||
| ['ńg', True, ''], | ||
| ]) | ||
| def test_to_finals_tone(pinyin, strict, result): | ||
| assert to_finals_tone(pinyin, strict=strict) == result | ||
|
|
@@ -317,6 +332,9 @@ def test_to_finals_tone(pinyin, strict, result): | |
| ['yū', True, True, False, 'ü1'], | ||
| ['yū', False, False, False, 'u1'], | ||
| ['yū', False, True, False, 'u1'], | ||
|
|
||
| ['ńg', False, False, False, 'n2g'], | ||
| ['ńg', True, False, False, ''], | ||
| ]) | ||
| def test_to_finals_tone2(pinyin, strict, v_to_u, | ||
| neutral_tone_with_five, result): | ||
|
|
@@ -336,6 +354,11 @@ def test_to_finals_tone2(pinyin, strict, v_to_u, | |
| ['yū', True, True, False, 'ü1'], | ||
| ['yū', False, False, False, 'u1'], | ||
| ['yū', False, True, False, 'u1'], | ||
|
|
||
| ['ńg', False, False, False, 'ng2'], | ||
| ['ňg', False, False, False, 'ng3'], | ||
| ['ǹg', False, False, False, 'ng4'], | ||
| ['ńg', True, False, False, ''], | ||
| ]) | ||
| def test_to_finals_tone3(pinyin, strict, v_to_u, neutral_tone_with_five, | ||
| result): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,22 @@ def test_issue_284(neutral_tone_with_five): | |
| neutral_tone_with_five=neutral_tone_with_five) == [''] | ||
|
|
||
|
|
||
| def test_finals_syllabic_ng_keeps_n(): | ||
| # 嗯 等字的 ńg/ňg/ǹg 读音在非严格模式下,韵母应是完整的 ``ng``, | ||
| # 而不是把声母 n 切掉后剩下的无效韵母 ``g``。 | ||
|
Comment on lines
+77
to
+78
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. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Use ASCII punctuation in these new comments. Lines 77-78 and Line 88 introduce fullwidth punctuation that Ruff reports as Also applies to: 88-88 🧰 Tools🪛 Ruff (0.15.20)[warning] 77-77: Comment contains ambiguous (RUF003) [warning] 77-77: Comment contains ambiguous (RUF003) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| finals = pinyin('嗯', style=Style.FINALS, heteronym=True, strict=False)[0] | ||
| assert 'ng' in finals | ||
| assert 'g' not in finals | ||
|
|
||
| tone3 = pinyin('嗯', style=Style.FINALS_TONE3, heteronym=True, | ||
| strict=False)[0] | ||
| assert 'ng2' in tone3 and 'ng3' in tone3 and 'ng4' in tone3 | ||
| assert 'g2' not in tone3 | ||
|
|
||
| # 严格模式(默认)下没有韵母的设计保持不变。 | ||
| assert pinyin('嗯', style=Style.FINALS, heteronym=True) == [['']] | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| import pytest | ||
| pytest.cmdline.main() | ||
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Replace the fullwidth punctuation in this new comment.
Lines 63-64 use fullwidth
(,), and,, which Ruff reports asRUF003. Please normalize them to ASCII so this change stays lint-clean.🧰 Tools
🪛 Ruff (0.15.20)
[warning] 63-63: Comment contains ambiguous
((FULLWIDTH LEFT PARENTHESIS). Did you mean((LEFT PARENTHESIS)?(RUF003)
[warning] 63-63: Comment contains ambiguous
)(FULLWIDTH RIGHT PARENTHESIS). Did you mean)(RIGHT PARENTHESIS)?(RUF003)
[warning] 63-63: Comment contains ambiguous
,(FULLWIDTH COMMA). Did you mean,(COMMA)?(RUF003)
[warning] 63-63: Comment contains ambiguous
,(FULLWIDTH COMMA). Did you mean,(COMMA)?(RUF003)
🤖 Prompt for AI Agents
Source: Linters/SAST tools