MIF_E31231430/find_all_math.py

13 lines
593 B
Python

import docx
path = "PERANCANGAN SISTEM REKOMENDASI KAMERA PADA PERSEWAAN KAMERA DENGAN BERBASIS WEBSITE MENGUNAKAN ALGORITMA TOPSIS (Revisi 6 fix bismillah).docx"
doc = docx.Document(path)
print("--- ALL EQUATION TEXTS IN THE DOCUMENT ---")
for idx, para in enumerate(doc.paragraphs):
math_para = para._p.find('.//{http://schemas.openxmlformats.org/officeDocument/2006/math}oMath')
if math_para is not None:
math_texts = [t.text for t in para._p.iter() if t.tag.endswith('}t')]
if math_texts:
print(f"Paragraph {idx} (text: '{para.text}'): {math_texts}")