@glyphp/resolver
v1.0.2
Published
Resolve natural-language intent to Glyph Protocol glyphs with pluggable scorers
Maintainers
Readme
@glyphp/resolver
Maps a natural-language intent to candidate glyphs, ranked by a pluggable Scorer.
Default — zero dependencies
import { GlyphResolver } from '@glyphp/resolver'
const lexicon = await client.getLexicon()
const resolver = new GlyphResolver(lexicon) // uses LexicalScorer by default
const matches = await resolver.resolve('buscar un paciente', { limit: 3 })
// → [{ entry: LexiconEntry, score: number }, ...] sorted best-firstLexicalScorer scores token overlap against each glyph's name, tags, and
intent (a name/tag hit outweighs an intent hit). No model, no network.
Opt-in — semantic embeddings
pnpm add @huggingface/transformersimport { GlyphResolver, createTransformersScorer } from '@glyphp/resolver'
const scorer = await createTransformersScorer() // downloads MiniLM on first run
const resolver = new GlyphResolver(lexicon, scorer)EmbeddingScorer ranks by cosine similarity. The embedding function is
injected, so any backend works — pass your own EmbedFn to new
EmbeddingScorer(embed) to use an API instead.
