test: generate test corpus for B1/B2/B3 (Word+Excel+PPTX+PDF with hyperlinks/footnotes/charts/SmartArt)
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m56s

This commit is contained in:
2026-07-14 17:52:06 +02:00
parent dd1e005c70
commit b706cbf802
6 changed files with 503 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
"""Quick verification of the test corpus."""
import zipfile
import fitz
print("=== test_word.docx ===")
with zipfile.ZipFile("sample_files/test_corpus/test_word.docx") as z:
has_fn = "word/footnotes.xml" in z.namelist()
rels = z.read("word/_rels/document.xml.rels").decode()
n_hl = rels.count('TargetMode="External"')
print(f" footnotes.xml: {has_fn}, external hyperlinks: {n_hl}")
print("=== test_excel.xlsx ===")
from openpyxl import load_workbook
wb = load_workbook("sample_files/test_corpus/test_excel.xlsx")
ws = wb["Sales"]
n_comments = sum(1 for row in ws.iter_rows() for c in row if c.comment)
n_hl = sum(1 for row in ws.iter_rows() for c in row if c.hyperlink)
n_charts = len(ws._charts) if hasattr(ws, "_charts") else 0
print(f" comments: {n_comments}, hyperlinks: {n_hl}, charts: {n_charts}")
print(f" sheets: {wb.sheetnames}")
print("=== test_pptx.pptx ===")
with zipfile.ZipFile("sample_files/test_corpus/test_pptx.pptx") as z:
has_diag = "ppt/diagrams/data1.xml" in z.namelist()
if has_diag:
diag = z.read("ppt/diagrams/data1.xml").decode()
n_texts = diag.count("<a:t>")
else:
n_texts = 0
print(f" diagrams/data1.xml: {has_diag}, <a:t> nodes: {n_texts}")
print("=== test_pdf.pdf ===")
doc = fitz.open("sample_files/test_corpus/test_pdf.pdf")
print(f" pages: {len(doc)}")
total_links = 0
total_images = 0
for p in doc:
total_links += len(p.get_links())
total_images += len(p.get_images())
print(f" total links: {total_links}, total images: {total_images}")
doc.close()