mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2026-11-17 18:43:37 +08:00
Merge 4b10d6d1d1964ba0d08033098014cf4ddcc4449e into 6d51ffceafbf240145619af4c92408a6e54b7924
This commit is contained in:
commit
de07700761
@ -116,7 +116,8 @@ def replace_date(match) -> str:
|
||||
|
||||
|
||||
# 用 / 或者 - 分隔的 YY/MM/DD 或者 YY-MM-DD 日期
|
||||
RE_DATE2 = re.compile(r"(\d{4})([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])")
|
||||
# 月和日也可以是一位数,如 2024/1/1
|
||||
RE_DATE2 = re.compile(r"(\d{4})([- /.])(0[1-9]|1[012]|[1-9])\2(0[1-9]|[12][0-9]|3[01]|[1-9](?!\d))")
|
||||
|
||||
|
||||
def replace_date2(match) -> str:
|
||||
|
||||
33
test_zh_normalization_date.py
Normal file
33
test_zh_normalization_date.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""Regressions for reading dates in Chinese text normalization, without loading any model."""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path[:0] = [str(Path(__file__).resolve().parent / "GPT_SoVITS")]
|
||||
from text.zh_normalization.text_normlization import TextNormalizer # noqa: E402
|
||||
|
||||
|
||||
class DateTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.normalizer = TextNormalizer()
|
||||
|
||||
def test_single_digit_month_and_day(self):
|
||||
self.assertEqual(self.normalizer.normalize_sentence("2024/1/1"), "二零二四年一月一日")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("2024-3-8"), "二零二四年三月八日")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("2024/1/31"), "二零二四年一月三十一日")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("2024/10/1"), "二零二四年十月一日")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("会议在2024/9/27举行"), "会议在二零二四年九月二十七日举行")
|
||||
|
||||
def test_two_digit_month_and_day(self):
|
||||
self.assertEqual(self.normalizer.normalize_sentence("2024/09/27"), "二零二四年九月二十七日")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("2024-01-01"), "二零二四年一月一日")
|
||||
|
||||
def test_not_a_date(self):
|
||||
self.assertEqual(self.normalizer.normalize_sentence("3/4"), "四分之三")
|
||||
self.assertNotIn("年", self.normalizer.normalize_sentence("2024/13/1"))
|
||||
self.assertNotIn("年", self.normalizer.normalize_sentence("2024/1/32"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
x
Reference in New Issue
Block a user