continue fixing
This commit is contained in:
@@ -351,6 +351,83 @@ def test_split_sentences_handles_ellipsis_and_dots_only():
|
||||
) == []
|
||||
|
||||
|
||||
def test_split_sentences_ignores_decimal_points():
|
||||
segment = TranscriptionSegment(
|
||||
start_seconds=0.0,
|
||||
end_seconds=6.0,
|
||||
text="The rate rose by 0.4%. That is a big jump.",
|
||||
)
|
||||
sentences = split_sentences_at_punctuation([segment])
|
||||
assert [s.text for s in sentences] == [
|
||||
"The rate rose by 0.4%.",
|
||||
"That is a big jump.",
|
||||
]
|
||||
|
||||
|
||||
def test_split_sentences_ignores_am_pm_abbreviations():
|
||||
segment = TranscriptionSegment(
|
||||
start_seconds=0.0,
|
||||
end_seconds=8.0,
|
||||
text=(
|
||||
"It was at 9 o'clock p.m. Eastern, President Trump was speaking. "
|
||||
"The room was quiet."
|
||||
),
|
||||
)
|
||||
sentences = split_sentences_at_punctuation([segment])
|
||||
assert [s.text for s in sentences] == [
|
||||
"It was at 9 o'clock p.m. Eastern, President Trump was speaking.",
|
||||
"The room was quiet.",
|
||||
]
|
||||
|
||||
morning = TranscriptionSegment(
|
||||
start_seconds=0.0,
|
||||
end_seconds=4.0,
|
||||
text="I woke up at 7 a.m. and had coffee. Then I left.",
|
||||
)
|
||||
sentences = split_sentences_at_punctuation([morning])
|
||||
assert [s.text for s in sentences] == [
|
||||
"I woke up at 7 a.m. and had coffee.",
|
||||
"Then I left.",
|
||||
]
|
||||
|
||||
|
||||
def test_split_sentences_merges_segment_ending_with_abbreviation():
|
||||
segments = [
|
||||
TranscriptionSegment(0.0, 5.0, "The meeting ends at 5 p.m."),
|
||||
TranscriptionSegment(5.0, 9.0, "Eastern time. Then we go home."),
|
||||
]
|
||||
sentences = split_sentences_at_punctuation(segments)
|
||||
assert [s.text for s in sentences] == [
|
||||
"The meeting ends at 5 p.m. Eastern time.",
|
||||
"Then we go home.",
|
||||
]
|
||||
|
||||
|
||||
def test_split_sentences_distinguishes_no_reply_from_number():
|
||||
reply = TranscriptionSegment(0.0, 4.0, "No. I don't think so.")
|
||||
assert [s.text for s in split_sentences_at_punctuation([reply])] == [
|
||||
"No.",
|
||||
"I don't think so.",
|
||||
]
|
||||
numbered = TranscriptionSegment(0.0, 4.0, "See no. 5 on the list.")
|
||||
assert [s.text for s in split_sentences_at_punctuation([numbered])] == [
|
||||
"See no. 5 on the list."
|
||||
]
|
||||
|
||||
|
||||
def test_split_sentences_ignores_common_abbreviations():
|
||||
segment = TranscriptionSegment(
|
||||
start_seconds=0.0,
|
||||
end_seconds=4.0,
|
||||
text="Dr. Smith said the U.S. economy is growing. He was right.",
|
||||
)
|
||||
sentences = split_sentences_at_punctuation([segment])
|
||||
assert [s.text for s in sentences] == [
|
||||
"Dr. Smith said the U.S. economy is growing.",
|
||||
"He was right.",
|
||||
]
|
||||
|
||||
|
||||
def test_post_audio_requests_word_timestamps_and_falls_back(monkeypatch):
|
||||
calls = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user