utils: don't consider colon an end of sentence
This commit is contained in:
@@ -56,6 +56,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- We don't consider a colon `:` and end of sentence any more.
|
||||||
|
|
||||||
- Updated `DailyTransport` to respect the `audio_in_stream_on_start` field,
|
- Updated `DailyTransport` to respect the `audio_in_stream_on_start` field,
|
||||||
ensuring it only starts receiving the audio input if it is enabled.
|
ensuring it only starts receiving the audio input if it is enabled.
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ ENDOFSENTENCE_PATTERN_STR = r"""
|
|||||||
(?<!Mr|Ms|Dr) # Negative lookbehind: not preceded by Mr, Ms, Dr (combined bc. length is the same)
|
(?<!Mr|Ms|Dr) # Negative lookbehind: not preceded by Mr, Ms, Dr (combined bc. length is the same)
|
||||||
(?<!Mrs) # Negative lookbehind: not preceded by "Mrs"
|
(?<!Mrs) # Negative lookbehind: not preceded by "Mrs"
|
||||||
(?<!Prof) # Negative lookbehind: not preceded by "Prof"
|
(?<!Prof) # Negative lookbehind: not preceded by "Prof"
|
||||||
[\.\?\!:;]| # Match a period, question mark, exclamation point, colon, or semicolon
|
[\.\?\!;]| # Match a period, question mark, exclamation point, or semicolon
|
||||||
[。?!:;।] # the full-width version (mainly used in East Asian languages such as Chinese, Hindi)
|
[。?!;।] # the full-width version (mainly used in East Asian languages such as Chinese, Hindi)
|
||||||
$ # End of string
|
$ # End of string
|
||||||
"""
|
"""
|
||||||
ENDOFSENTENCE_PATTERN = re.compile(ENDOFSENTENCE_PATTERN_STR, re.VERBOSE)
|
ENDOFSENTENCE_PATTERN = re.compile(ENDOFSENTENCE_PATTERN_STR, re.VERBOSE)
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class TestUtilsString(unittest.IsolatedAsyncioTestCase):
|
|||||||
assert match_endofsentence("This is a sentence.")
|
assert match_endofsentence("This is a sentence.")
|
||||||
assert match_endofsentence("This is a sentence! ")
|
assert match_endofsentence("This is a sentence! ")
|
||||||
assert match_endofsentence("This is a sentence?")
|
assert match_endofsentence("This is a sentence?")
|
||||||
assert match_endofsentence("This is a sentence:")
|
|
||||||
assert match_endofsentence("This is a sentence;")
|
assert match_endofsentence("This is a sentence;")
|
||||||
assert not match_endofsentence("This is not a sentence")
|
assert not match_endofsentence("This is not a sentence")
|
||||||
assert not match_endofsentence("This is not a sentence,")
|
assert not match_endofsentence("This is not a sentence,")
|
||||||
@@ -33,7 +32,6 @@ class TestUtilsString(unittest.IsolatedAsyncioTestCase):
|
|||||||
"你好!",
|
"你好!",
|
||||||
"吃了吗?",
|
"吃了吗?",
|
||||||
"安全第一;",
|
"安全第一;",
|
||||||
"他说:",
|
|
||||||
]
|
]
|
||||||
for i in chinese_sentences:
|
for i in chinese_sentences:
|
||||||
assert match_endofsentence(i)
|
assert match_endofsentence(i)
|
||||||
|
|||||||
Reference in New Issue
Block a user