"""Numbers on the six slide cards (bullets only) vs numbers printed in the pasted tables. Usage: python -I trace_docx.py results-deck-outline.docx tables_pasted.txt"""
import re, sys
from docx import Document
doc = Document(sys.argv[1]); ex = open(sys.argv[2], encoding='utf-8').read()
NUM = re.compile(r"(?<![\w.])-?\d+(?:\.\d+)?")
def strip(s):
    s = s.replace('−', '-')
    s = re.sub(r"Table\s+14-\d\.\d\d|\b14-\d\.\d\d\b", " ", s); s = re.sub(r"\bpp?\.\s*\d+(?:-\d+)?", " ", s)
    s = re.sub(r"ADAS[ -]?Cog\s*\(11\)", "ADAS-Cog", s); s = re.sub(r"\[\d\]", " ", s); s = re.sub(r"\bWeek\s+24\b", "Week", s)
    return s
src = set(NUM.findall(strip(ex))); found = []
for t in doc.tables:
    if len(t.rows) == 3 and len(t.columns) == 1:
        c = t.rows[1].cells[0]
        for p in c.paragraphs[2:]:   # skip title and source line
            found += NUM.findall(strip(p.text))
miss = sorted({n for n in found if n not in src})
print('numbers on card bullets:', len(found), 'distinct', len(set(found)), 'not in the pasted tables:', miss)
