fix(data-process): 合并文档结构短切片
This commit is contained in:
@@ -1402,7 +1402,6 @@ def test_every_unstructured_preprocess_option_changes_preview_behavior() -> None
|
||||
)
|
||||
assert without_merge[0]["token_count"] < 5
|
||||
assert with_merge[0]["token_count"] >= 5
|
||||
|
||||
mojibake = "这是无法可靠读取的内容,锟斤拷锟斤拷锟斤拷,需要预先过滤。"
|
||||
assert len(_preview_task(mojibake, options=[])) == 1
|
||||
assert _preview_task(mojibake, options=["filter_low_quality"]) == []
|
||||
@@ -1451,6 +1450,25 @@ def test_every_unstructured_preprocess_option_changes_preview_behavior() -> None
|
||||
assert "[EMAIL]" in masked["edited_content"]
|
||||
|
||||
|
||||
def test_merge_short_content_applies_across_adjacent_structure_sections() -> None:
|
||||
content = "\n".join(f"{index}. 小节{index}\n内容{index}。" for index in range(1, 9))
|
||||
items = _preview_task(
|
||||
content,
|
||||
options=["merge_short_content"],
|
||||
config={
|
||||
"chunk_method": "structure",
|
||||
"chunk_size": 40,
|
||||
"chunk_overlap": 0,
|
||||
"min_chunk_size": 20,
|
||||
},
|
||||
)
|
||||
|
||||
assert len(items) == 2
|
||||
assert all(20 <= item["token_count"] <= 40 for item in items)
|
||||
assert items[0]["source_start_line"] == 1
|
||||
assert items[0]["source_end_line"] == 8
|
||||
|
||||
|
||||
def test_stored_binary_document_text_is_not_reparsed_as_binary() -> None:
|
||||
for file_format in ("pdf", "docx", "pptx"):
|
||||
items = _preview_task(
|
||||
|
||||
Reference in New Issue
Block a user