tts-evaluation / rubric_reader.py
kathiasi's picture
Initiation
9129e20 verified
from docx import Document
import os
def read_docx_rubric(path):
"""Read a .docx rubric and return a list of paragraphs (stripped).
If the file contains clearly labeled criteria (e.g., numbered or bold lines),
this will return a list of non-empty lines to be used as criteria.
"""
if not os.path.exists(path):
return []
doc = Document(path)
texts = []
for p in doc.paragraphs:
t = p.text.strip()
if t:
texts.append(t)
return texts