ai insight rework #1

This commit is contained in:
Alberto-Audrix committed 2026-09-29 15:19:10 +07:00
1 parent 0d960c8153
commit 9d76f54d33
13 files changed
+730 -299

No files matched your search

+12 -5
View File
@@ -27,18 +27,25 @@ def extract_docx(file_path):
full_text.append(para.text)
elif tag.endswith('tbl'):
table = Table(element, doc)
table_text = []
table_rows = []
for row in table.rows:
row_text = []
for cell in row.cells:
text = cell.text.strip()
text = cell.text.strip().replace("|", "/").replace("\n", " ")
# Hindari duplikasi text sel gabungan (merged cells) secara berturut-turut
if not row_text or row_text[-1] != text:
row_text.append(text)
if row_text:
table_text.append(" | ".join(row_text))
if table_text:
full_text.append("\n".join(table_text))
table_rows.append(row_text)
if table_rows:
# Plan Stage 2: GFM markdown table, header row preserved for RAG.
header = table_rows[0]
md_lines = [
"| " + " | ".join(header) + " |",
"| " + " | ".join(["---"] * len(header)) + " |",
]
md_lines += ["| " + " | ".join(r) + " |" for r in table_rows[1:]]
full_text.append("\n" + "\n".join(md_lines) + "\n")
return "\n\n".join(full_text)