MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / build_norm_index

Function build_norm_index

openkb/lint.py:50–60  ·  view source on GitHub ↗

Build the normalized-form → canonical-target index used by :func:`strip_ghost_wikilinks`. Useful when calling ``strip_ghost_wikilinks`` repeatedly with the same ``known_targets`` (e.g. ``fix_broken_links`` scanning N wiki files, or ``_save_transcript`` stripping N assistant turns) —

(known_targets: set[str])

Source from the content-addressed store, hash-verified

48
49
50def build_norm_index(known_targets: set[str]) -> dict[str, str]:
51 """Build the normalized-form → canonical-target index used by
52 :func:`strip_ghost_wikilinks`.
53
54 Useful when calling ``strip_ghost_wikilinks`` repeatedly with the same
55 ``known_targets`` (e.g. ``fix_broken_links`` scanning N wiki files, or
56 ``_save_transcript`` stripping N assistant turns) — build the index
57 once and pass it via the ``norm_index`` parameter to avoid O(N·M)
58 redundant rebuilds.
59 """
60 return {_normalize_target(t): t for t in known_targets}
61
62
63def strip_ghost_wikilinks(

Calls 1

_normalize_targetFunction · 0.85