feat: add ImageFind application and release pipelines
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from imagefind.subtitles import parse_subtitles, timestamp_ms
|
||||
from imagefind.text import fts_query, normalize_text, search_tokens
|
||||
|
||||
|
||||
def test_chinese_and_english_tokens_are_stable():
|
||||
tokens = search_tokens("红色汽车 Red-Car 订单A12")
|
||||
assert "红色" in tokens
|
||||
assert "汽车" in tokens
|
||||
assert "red-car" in tokens
|
||||
assert "a12" in tokens
|
||||
assert normalize_text(" ABC ") == "abc"
|
||||
assert '"红色"' in fts_query("红色")
|
||||
|
||||
|
||||
def test_srt_and_vtt_parser():
|
||||
cues = parse_subtitles(
|
||||
"""WEBVTT
|
||||
|
||||
00:00:01.200 --> 00:00:03.400
|
||||
<b>你好</b> world
|
||||
|
||||
00:01:10,000 --> 00:01:11,500
|
||||
第二行
|
||||
"""
|
||||
)
|
||||
assert [(cue.start_ms, cue.end_ms, cue.text) for cue in cues] == [
|
||||
(1200, 3400, "你好 world"),
|
||||
(70000, 71500, "第二行"),
|
||||
]
|
||||
assert timestamp_ms("1:02:03.045") == 3_723_045
|
||||
Reference in New Issue
Block a user