Complete a prefix
Rank next-word candidates with
Complete().
const results = chain.Complete("goodbye", { limit: 5, minCount: 1,});1. probe = Create(prefix).glyph2. tokens = CreateUnigrams(prefix) // TextStrip — letters/digits only3. if tokens.length < order - 1 → return []4. stateKey = last (order - 1) tokens joined5. candidates = transitions from stateKey6. score each candidate by weighted glyph similarity to probe7. sort by score desc → count desc → token asc8. apply minCount, then limitScoring
Section titled “Scoring”Markov structure defines which tokens are valid. Glyph similarity defines rank.
glyphScore = sum(weight_i * CompareGlyphs(probe, source_i).similarity) / sum(weight_i)| Rank factor | Role |
|---|---|
score |
Primary sort (glyph-guided) |
count |
Tiebreak when scores are equal |
token |
Lexical tiebreak for stability |
Occurrence count does not drive primary rank. It only filters candidates (
minCount) and breaks ties.
Completions vs query
Section titled “Completions vs query”| Use | API |
|---|---|
| Find similar documents | Query |
| Suggest the next word in a prefix | Completions |