import re,sys,os
sys.path.insert(0,os.path.dirname(__file__))
from rows import ROWS
d=os.path.join(os.path.dirname(__file__),"..","files")
A=open(d+"/document_A_FDA_minutes_excerpt.txt",encoding="utf8").read()
B=open(d+"/document_B_INVENTED_team_notes.txt",encoding="utf8").read()
n=lambda s:re.sub(r"\s+"," ",s).lower()
A,B=n(A),n(B)
bad=0
def frags(q):
    return [f.strip(" .") for f in q.split("...") if f.strip(" .")]
for r in ROWS:
    num,_,mq,nq=r[:4]
    for f in frags(mq):
        ok=n(f) in A; bad+=not ok; print(num,"A",ok,"" if ok else f)
    if not nq.startswith("not recorded"):
        for f in frags(nq): 
            ok=n(f) in B; bad+=not ok; print(num,"B",ok,"" if ok else f)
    else:
        for q in re.findall(r'"([^"]+)"',nq):
            for f in frags(q):
                ok=n(f) in B; bad+=not ok; print(num,"B(inner)",ok,"" if ok else f)
print("FAILED:",bad)
