GST_RAG_BACKEND / app /ingestion /docx_reader.py
Samaksh25's picture
fix(retrieval): CrossEncoder ms-marco + PRF + synonym expansion
6733714
Raw
History Blame Contribute Delete
427 Bytes
from docx import Document
def extract_text_from_docx(path):
doc = Document(path)
text_blocks = []
full_text = "\n".join(
p.text for p in doc.paragraphs if p.text.strip()
)
if full_text.strip():
text_blocks.append({
"text": full_text,
"metadata": {
"source": str(path),
"type": "docx"
}
})
return text_blocks