This commit is contained in:
512song committed 2025-08-13 20:36:47 +08:00
1 parent c0db3d691e
commit dcbfb8f1eb
5 files changed
+592 -384

No files matched your search

+65 -29
View File
@@ -414,25 +414,9 @@
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-09T02:47:43.965042Z",
"iopub.status.busy": "2025-03-09T02:47:43.964342Z",
"iopub.status.idle": "2025-03-09T02:47:44.398962Z",
"shell.execute_reply": "2025-03-09T02:47:44.398531Z",
"shell.execute_reply.started": "2025-03-09T02:47:43.964980Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'list'>\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
"import re\n",
@@ -482,16 +466,8 @@
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-09T02:36:40.207084Z",
"iopub.status.busy": "2025-03-09T02:36:40.206317Z",
"iopub.status.idle": "2025-03-09T02:36:40.223987Z",
"shell.execute_reply": "2025-03-09T02:36:40.223140Z",
"shell.execute_reply.started": "2025-03-09T02:36:40.207017Z"
}
},
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
@@ -1600,6 +1576,66 @@
"# print(err)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pymupdf4llm\n",
"#md_text = pymupdf4llm.to_markdown(\"data/1782596-唐荣.pdf\")\n",
"llama_reader = pymupdf4llm.LlamaMarkdownReader()\n",
"llama_docs = llama_reader.load_data(\"data/1782596-唐荣.pdf\")\n",
"\n",
"print(llama_docs)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pymupdf4llm\n",
"md_text = pymupdf4llm.to_markdown(\"data/1782596-唐荣.pdf\")\n",
"#llama_reader = pymupdf4llm.LlamaMarkdownReader()\n",
"#llama_docs = llama_reader.load_data(\"data/1782596-唐荣.pdf\")\n",
"\n",
"print(md_text)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"execution": {
"iopub.execute_input": "2025-08-05T04:13:25.191718Z",
"iopub.status.busy": "2025-08-05T04:13:25.191013Z",
"iopub.status.idle": "2025-08-05T04:13:26.589724Z",
"shell.execute_reply": "2025-08-05T04:13:26.589155Z",
"shell.execute_reply.started": "2025-08-05T04:13:25.191654Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'metadata': {'format': 'PDF 1.5', 'title': '', 'author': 'FastReport', 'subject': 'FastReport PDF export', 'keywords': '', 'creator': '', 'producer': '', 'creationDate': 'D:20250628093605', 'modDate': 'D:20250628093605', 'trapped': '', 'encryption': None, 'file_path': 'data/1782596-唐荣.pdf', 'page_count': 12, 'page': 1}, 'toc_items': [], 'tables': [], 'images': [{'number': 4, 'bbox': Rect(233.94000244140625, 713.0, 375.66998291015625, 854.72998046875), 'transform': (141.72999572753906, 0.0, -0.0, 141.72999572753906, 233.94000244140625, 713.0), 'width': 190, 'height': 190, 'colorspace': 3, 'cs-name': 'DeviceRGB', 'xres': 96, 'yres': 96, 'bpc': 8, 'size': 15730, 'has-mask': False}, {'number': 11, 'bbox': Rect(251.69000244140625, 279.6000061035156, 353.739990234375, 387.32000732421875), 'transform': (102.05000305175781, 0.0, -0.0, 107.72000122070312, 251.69000244140625, 279.6000061035156), 'width': 137, 'height': 145, 'colorspace': 3, 'cs-name': 'DeviceRGB', 'xres': 96, 'yres': 96, 'bpc': 8, 'size': 7001, 'has-mask': False}], 'graphics': [], 'text': '```\\n 医保卡号:\\n\\n 体检号:325031000089\\n 检查类型:在岗期间\\n\\n# **`南京江北医院`** **`职业健康检查表`**\\n\\n```\\n\\n#### `体检编号` `姓 名`\\n\\n\\n#### `325031000089` `唐荣`\\n\\n\\n#### `身 份 证 32011219771117****`\\n\\n\\n#### `用人单位`\\n\\n\\n```\\n南化公司苯化工部\\n\\n```\\n\\n#### `联系电话 13382785142`\\n\\n\\n', 'words': []}, {'metadata': {'format': 'PDF 1.5', 'title': '', 'author': 'FastReport', 'subject': 'FastReport PDF export', 'keywords': '', 'creator': '', 'producer': '', 'creationDate': 'D:20250628093605', 'modDate': 'D:20250628093605', 'trapped': '', 'encryption': None, 'file_path': 'data/1782596-唐荣.pdf', 'page_count': 12, 'page': 2}, 'toc_items': [], 'tables': [], 'images': [], 'graphics': [], 'text': '## **`职业健康检查表说明`**\\n\\n#### `一、本单位保证职业健康检查的科学性、公正性和准确性。` `二、本单位职业健康检查活动依据国家《职业健康检查管理办法》、《` `职业健康监护技术规范》等规定进行。` `三、本单位《江苏省职业健康检查机构备案回执》的编号:苏卫职检` `备字[2021]BG第016号` `四、本检查表涂改、增删无效,未加盖单位印章无效。` `五、未经本单位同意,不得部分复制本检查表。` `六、用人单位和劳动者应确保一般项目、职业史、接触的职业病危害` `因素、既往病史等项目的真实性。` `七、发现健康损害或者疑似职业病病人时,用人单位应根据本单位的` `主检意见及国家法律法规要求安排复查或医学观察或进行职业病` `诊断。` `八、对检查结果若有异议,可直接向本单位进行咨询。` `地址(Address):南京市化工园区葛关路552号` `邮政编码(Post Coad):210048` `电话(Tel):025-57067000`\\n\\n\\n', 'words': []}, {'metadata': {'format': 'PDF 1.5', 'title': '', 'author': 'FastReport', 'subject': 'FastReport PDF export', 'keywords': '', 'creator': '', 'producer': '', 'creationDate': 'D:20250628093605', 'modDate': 'D:20250628093605', 'trapped': '', 'encryption': None, 'file_path': 'data/1782596-唐荣.pdf', 'page_count': 12, 'page': 3}, 'toc_items': [], 'tables': [{'bbox': (57.689998626708984, 206.18099975585938, 562.260009765625, 297.70001220703125), 'rows': 2, 'columns': 6}, {'bbox': (57.689998626708984, 315.7010192871094, 562.260009765625, 367.9800109863281), 'rows': 2, 'columns': 5}], 'images': [], 'graphics': [], 'text': '```\\n 中华人民共和国预防性健康检查用表\\n\\n### **`有害作业人员健康检查表`**\\n\\n```\\n\\n```\\n单位名称:\\n\\n```\\n\\n```\\n南化公司苯化工部\\n\\n```\\n\\n```\\n1977年11月17日\\n\\n```\\n\\n```\\n姓 名: 唐荣 性 别:男\\n\\n```\\n\\n```\\n出生年月:\\n\\n```\\n\\n```\\n国 籍:中华人民共和国\\n\\n```\\n\\n```\\n民 族:汉族 婚 否: /\\n\\n```\\n\\n```\\n0 月 接害工龄:20 年 0 月\\n\\n```\\n\\n```\\n体检日期:\\n\\n```\\n\\n```\\n总 工 龄: 29 年 0 月 接害工龄:\\n\\n```\\n\\n```\\n年 0 月 接害工龄:20 年\\n\\n```\\n\\n```\\n2025年03月10日\\n\\n```\\n\\n```\\n29 0 20\\n\\n```\\n\\n```\\n接触有害因素:\\n\\n```\\n\\n```\\n苯,苯胺,硝基苯,硫酸及三氧化硫,硝酸,氮氧化物,氢氧化钠,氢气\\n\\n```\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n|一、职业史|Col2|Col3|Col4|Col5|Col6|\\n|---|---|---|---|---|---|\\n|`起止日期`|`工作单位`|`部门`|`工种`|` 有害因素种类、`<br>`名称`|`防护措施`|\\n|`2005-03-10-`<br>`至今`|`南化公司苯化工部`|`苯胺作业区`|`有机合成工`|`苯,苯胺,硝基苯,`<br>`硫酸及三氧化硫,`<br>`硝酸,氮氧化物,氢`<br>`氧化钠,氢气`|`口罩,手套,耳塞`|\\n\\n\\n\\n|二、既往病史|Col2|Col3|Col4|Col5|\\n|---|-Line truncated
]
}
],
"source": [
"from pathlib import Path\n",
"import json\n",
"import shutil\n",
"import pymupdf4llm\n",
"#md_text = pymupdf4llm.to_markdown(\"data/1782596-唐荣.pdf\")\n",
"#llama_reader = pymupdf4llm.LlamaMarkdownReader()\n",
"llama_docs = pymupdf4llm.to_markdown(\"data/1782596-唐荣.pdf\",page_chunks=True)\n",
"print(llama_docs)"
]
},
{
"cell_type": "code",
"execution_count": null,