exec(open('sim6.py').read().split('if __name__')[0]) HASSTRUCT=set(adj.keys()) print("nodes with >=1 structural edge:",len(HASSTRUCT),file=sys.stderr) def run2(sfilter, seedout, lim=10): res={} for qid,q in gold.items(): v=emb(q['query']); s=M@v; s[~np.isfinite(s)]=-1 L,nmatch=lexleg(qid,q['query']) if nmatch==0: res[qid]=[]; continue ordr=np.argsort(-s) cand=[eids[j] for j in ordr[:200] if PRINT.match(eids[j] or '')] S=[x for x in cand if (not sfilter or x in HASSTRUCT)][:10] seeds=[x for x in L[:3] if x in N] semseeds=[eids[j] for j in ordr[:8] if eids[j] in N and eids[j] not in seeds and PRINT.match(eids[j] or '')] seeds=seeds+semseeds A=assoc(seeds,s,False,'cos') if seeds else [] if seedout: extra=[(float(s[eidx[x]]),x) for x in semseeds if x in HASSTRUCT and x in eidx] merged=[(float(s[eidx[x]]),x) for x in A if x in eidx]+extra merged.sort(reverse=True) seen=set(); A=[] for c,x in merged: if x in seen: continue seen.add(x); A.append(x) A=A[:ASSOC_MAX] res[qid]=inter([L,S,A]) return res b,_=run(True,False,False,'cos'); base=score(b,'BASE bm25lex replica') a,_=run(False,True,False,'cos'); score(a,'A floor-off+vocabgate',base) score(run2(False,True),'E A+struct-seeds-in-graphleg',base) score(run2(True,False),'F A+S-restricted-to-graph',base) score(run2(True,True),'G E+F',base)