Files
HC900-Crawler/mcp-server/parsers/pdf_parser.py
windpacer 16fc7a2598 Initial commit: HC900 Crawler
Honeywell HC900을 Modbus TCP로 직접 폴링 → gRPC → C# 크롤러 → PostgreSQL.
기존 Experion OPC UA 데이터 경로를 HC900 직접 통신으로 대체.

- industrial-comm/cpp: C++ Modbus 게이트웨이 (gRPC 서버)
- src: C# .NET 8 ASP.NET Core 크롤러 + 웹 UI (3-Layer)
- mcp-server: Python FastMCP (RAG/NL2SQL/P&ID)
- 다중 컨트롤러(N-Controller) 지원

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:28:14 +09:00

35 lines
1.1 KiB
Python

"""pdf 청킹 — pdfplumber로 페이지/표 추출, 헤딩 분리 실패 시 페이지 단위 fallback."""
from __future__ import annotations
def parse(path: str) -> list[dict]:
import pdfplumber
chunks: list[dict] = []
with pdfplumber.open(path) as pdf:
for pno, page in enumerate(pdf.pages, start=1):
txt = (page.extract_text() or "").strip()
if txt:
chunks.append({
"text": txt[:5000],
"chunk_kind": "page",
"locator": f"page={pno}",
})
try:
tables = page.extract_tables() or []
except Exception:
tables = []
for ti, table in enumerate(tables, start=1):
rows = [[(c or "").strip() for c in row] for row in table if row]
if not rows:
continue
md = "\n".join(" | ".join(r) for r in rows[:200])
chunks.append({
"text": md,
"chunk_kind": "table",
"locator": f"page={pno}; table={ti}",
})
return chunks