26-7-31-1

This commit is contained in:
shuai
2026-07-31 12:27:41 +08:00
commit 9b8b8b57b3
142 changed files with 22408 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
from pathlib import Path
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE
p = Path(r"E:\桌面\实训项目\smart-hospital\ppt\智慧医院_AI影像诊断与电子病历辅助决策系统_答辩PPT.pptx")
prs = Presentation(str(p))
def box(sh):
return (sh.left, sh.top, sh.left + sh.width, sh.top + sh.height)
def area(b):
return max(0, b[2] - b[0]) * max(0, b[3] - b[1])
def inter(a, b):
l = max(a[0], b[0])
t = max(a[1], b[1])
r = min(a[2], b[2])
btm = min(a[3], b[3])
if r <= l or btm <= t:
return 0
return (r - l) * (btm - t)
def label(sh):
if sh.shape_type == MSO_SHAPE_TYPE.PICTURE:
return "[IMG]"
if sh.has_table:
return "[TABLE]"
t = ""
if hasattr(sh, "text") and sh.text:
t = sh.text.replace("\n", " ").strip()[:50]
return t or f"shape#{sh.shape_id}"
for si, s in enumerate(prs.slides, 1):
shapes = list(s.shapes)
boxes = [(box(sh), label(sh), sh) for sh in shapes]
issues = []
for i in range(len(boxes)):
for j in range(i + 1, len(boxes)):
bi, bj = boxes[i][0], boxes[j][0]
ia = inter(bi, bj)
if ia <= 0:
continue
min_a = min(area(bi), area(bj))
if min_a == 0:
continue
ratio = ia / min_a
# intentional: text on colored bar, footer text on footer bar
# report if ratio high and not pure containment of tiny text in bar
if ratio < 0.25:
continue
t1, t2 = boxes[i][1], boxes[j][1]
# skip text fully inside same-color header/footer style if one is short page num
issues.append((ratio, t1, t2, bi, bj))
# also content past footer
footer_y = int(7.15 * 914400)
overflow = []
for b, lab, sh in boxes:
if b[1] < footer_y < b[3] and b[3] - footer_y > 50000 and "仅供教学" not in lab and " / " not in lab:
# shape crosses into footer zone
if sh.shape_type == MSO_SHAPE_TYPE.PICTURE or sh.has_table or (hasattr(sh, "text") and len(sh.text) > 20):
overflow.append(lab)
if issues or overflow:
print(f"=== Slide {si} overlaps={len(issues)} overflow={len(overflow)} ===")
for ratio, t1, t2, bi, bj in sorted(issues, reverse=True)[:10]:
print(f" r={ratio:.2f}")
print(f" A: {t1}")
print(f" B: {t2}")
print(
f" A inches: L={bi[0]/914400:.2f} T={bi[1]/914400:.2f} R={bi[2]/914400:.2f} B={bi[3]/914400:.2f}"
)
print(
f" B inches: L={bj[0]/914400:.2f} T={bj[1]/914400:.2f} R={bj[2]/914400:.2f} B={bj[3]/914400:.2f}"
)
for o in overflow:
print(f" FOOTER CROSS: {o}")