Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from unstructured.partition.auto import partition
|
||||
|
||||
# PDF文件路径
|
||||
pdf_path = "../../data/C2/pdf/rag.pdf"
|
||||
|
||||
# 使用Unstructured加载并解析PDF文档
|
||||
elements = partition(
|
||||
filename=pdf_path,
|
||||
content_type="application/pdf"
|
||||
)
|
||||
|
||||
# 打印解析结果
|
||||
print(f"解析完成: {len(elements)} 个元素, {sum(len(str(e)) for e in elements)} 字符")
|
||||
|
||||
# 统计元素类型
|
||||
from collections import Counter
|
||||
types = Counter(e.category for e in elements)
|
||||
print(f"元素类型: {dict(types)}")
|
||||
|
||||
# 显示所有元素
|
||||
print("\n所有元素:")
|
||||
for i, element in enumerate(elements, 1):
|
||||
print(f"Element {i} ({element.category}):")
|
||||
print(element)
|
||||
print("=" * 60)
|
||||
Reference in New Issue
Block a user