export type HGNode = { id:string; type:string; label:string; weight?:number };
export type HGEdge = { from:string; to:string; type:string; weight?:number };
export type HG = { nodes: Record<string, HGNode>; edges: HGEdge[] };
const mem: HG = { nodes:{}, edges:[] };
export function addText(userText:string, assistantText:string){
const ents = extract(userText + ' ' + assistantText);
for(const e of ents){ ensureNode(e.id, e.type, e.label); }
export function ensureNode(id:string, type:string, label:string){ if(!mem.nodes[id]) mem.nodes[id] = { id, type, label, weight:1 }; else mem.nodes[id].weight = (mem.nodes[id].weight||1) + 1; }