Skip to content

Main content

Prefix Trie Completion Explicit Score Order

Order explicit scored prefix completions by descending score with stable source ties, retaining distinct occurrence IDs; no authoritative autocomplete dictionary.

Loading tool…

Description

Order explicit scored prefix completions by descending score with stable source ties, retaining distinct occurrence IDs; no authoritative autocomplete dictionary.

A trie stores literal words as root-to-node character paths, with terminal flags marking complete words. A terminal can also have children, and an existing prefix path need not be a stored word. This family uses one UTF-16 code unit per ordinary edge, so code-unit length differs from a displayed character or Unicode code-point count.

Order explicit scored prefix completions by descending score with stable source ties, retaining distinct occurrence IDs; no authoritative autocomplete dictionary.

When to use this tool

Use this tool to order explicit scored prefix completions by descending score with stable source ties, retaining distinct occurrence IDs; no authoritative autocomplete dictionary.

How to use the tool and how it works

  1. Enter words, scores, prefix using the definitions below.
  2. Run the operation. Resolve input-format errors before interpreting an output.
  3. Read result.completions, using the stated boundary, ordering, sign and absence conventions.

Require aligned words and finite scores. Keep literal prefix matches and sort by descending score, resolving ties by original index; return word, score and index.1

Input fieldMeaning and unitsAccepted input
wordsExplicit literal word strings in caller order; construction limits each word to 127 code units.Dense list of at most 128 literal strings, each at most 8,192 UTF-16 units.
scoresFinite numeric ranking scores aligned with words; higher sorts earlier.Dense list of at most 128 finite numbers, under the stated integer/range rules.
prefixLiteral prefix; an empty prefix refers to the whole stored word set.Text, at most 8,192 UTF-16 code units; narrower grammar/range rules also apply.
Output fieldInterpretation
resultObject containing the fields below.
result.completionsLiteral prefix matches, in node order or explicit score order as stated above.
json
{
  "input": {
    "words": [
      "ab",
      "a",
      "b"
    ],
    "scores": [
      1,
      2,
      3
    ],
    "prefix": "a"
  },
  "output": {
    "result": {
      "completions": [
        {
          "word": "a",
          "score": 2,
          "index": 1
        },
        {
          "word": "ab",
          "score": 1,
          "index": 0
        }
      ]
    }
  }
}

Limitations and assumptions

  • Words remain occurrence records, including duplicates. Scores are caller-provided ranking values rather than inferred probabilities.
  • Ordinary node tables have at most 128 nodes with distinct IDs 0–127, one root ID 0 with empty character and null parent, unique parent/character edges, complete acyclic parent links and a boolean terminal flag. Every nonroot character is exactly one UTF-16 code unit.
  • Every declared outer field is required and unknown outer fields are rejected. Strings and JSON text have size limits, lists are bounded to 128 entries, and JSON nesting/node counts are bounded. Tighter operation-specific bounds stated above take precedence.
  • Ordinary numeric outputs must be finite and within safe-integer magnitude. Exact large lengths/counts use decimal strings. Original record indexes and code-unit positions are zero-based; span ends are exclusive unless stated otherwise.

Alternative or Complementary methods

Choose word membership, prefix existence, completion or ranking according to the question. Normalize text separately if needed; these operations preserve exact code units and caller order.

References

  1. Tool behavior and example: Prefix Trie Completion Explicit Score Order — tool.io

Similar or alternative tools

  • Prefix Trie Literal Prefix Completion Count

    Bounded explicit prefix trie with root ID 0, unique sibling UTF-16 code-unit edges and terminal flags; count distinct terminal completions, not duplicate original word observations or inferred dictionary frequencies.

  • Prefix Trie Literal Prefix Completion List

    Bounded explicit prefix trie with root ID 0, unique sibling UTF-16 code-unit edges and terminal flags; select terminal word completions in source-node order, including the prefix itself if terminal.