Description
Build a literal prefix trie from supplied lowercase ASCII words and generate prefix queries with traversal paths, exact descendant matches, duplicate word counts and possible missing-edge controls.
A parser corpus pairs literal input spellings or structured documents with observable parser results or explicitly constructed expectations. Successful parsing, semantic validity, and exact round-trip preservation are separate properties, so test records retain the relevant evidence.
Build a literal prefix trie from supplied lowercase ASCII words and generate prefix queries with traversal paths, exact descendant matches, duplicate word counts and possible missing-edge controls.
When to use this tool
Use this generator to create reproducible prefix trie lookup corpus cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply words, queryCount in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read nodes, wordCounts, queries. Use the conventions below and keep answer-bearing fields separate when presenting an exercise.
Build a code-point trie from supplied words and count repeated words. Sample prefixes, including empty and appended-hash probes, then return visited node IDs, whether the prefix path exists, and lexically sorted terminal-word matches below it.1
Delegated operations used for this result: word frequency. Their calculation or parsing conventions apply to the corresponding result fields.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| words | Words | Required. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 16.; minimum items 1; maximum items 16. |
| queryCount | Query Count | Required. Safe integer; minimum 1; maximum 16. |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| nodes | Nodes | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 257. |
| nodes[].id | Literal identifier used to match records, independently of their display labels. | Required. Safe integer; minimum 0; maximum 256. |
| nodes[].parent | Parent | Required. Safe integer; minimum 0; maximum 256. or Null. |
| nodes[].character | Character | Required. Text; maximum UTF-16 length 1. |
| nodes[].terminal | Terminal | Required. Boolean. |
| wordCounts | Word Counts | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 16. |
| wordCounts[].word | Word | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 16. |
| wordCounts[].count | Requested count; the mechanics explain whether one draw expands into several returned records. | Required. Safe integer; minimum 1; maximum 16. |
| queries | Queries | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 16. |
| queries[].prefix | Prefix | Required. Text; maximum UTF-16 length 17. |
| queries[].visitedIds | Visited Ids | Required. Array of Safe integer; minimum 0; maximum 256.; minimum items 0; maximum items 17. |
| queries[].found | Found | Required. Boolean. |
| queries[].matches | Matches | Required. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 16.; minimum items 0; maximum items 16. |
| randomness | Replay metadata: source is seed or context; seed is the normalized 32-bit seed or null for a context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional numeric replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"words": [
"car",
"cat"
],
"queryCount": 2,
"seed": 42
},
"output": {
"nodes": [
{
"id": 0,
"parent": null,
"character": "",
"terminal": false
},
{
"id": 1,
"parent": 0,
"character": "c",
"terminal": false
},
{
"id": 2,
"parent": 1,
"character": "a",
"terminal": false
},
{
"id": 3,
"parent": 2,
"character": "r",
"terminal": true
},
{
"id": 4,
"parent": 2,
"character": "t",
"terminal": true
}
],
"wordCounts": [
{
"word": "car",
"count": 1
},
{
"word": "cat",
"count": 1
}
],
"queries": [
{
"prefix": "ca",
"visitedIds": [
0,
1,
2
],
"found": true,
"matches": [
"car",
"cat"
]
},
{
"prefix": "cat",
"visitedIds": [
0,
1,
2,
4
],
"found": true,
"matches": [
"cat"
]
}
],
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- A found prefix need not itself be a complete word. Duplicate words share a terminal node but retain counts. The supported word bank and lexical ordering are literal rather than linguistic search semantics.
- A replay requires the same complete input and implementation. Randomized construction does not guarantee uniform coverage of every feasible output; finite samples can repeat unless a distinct-selection rule is explicitly stated.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Random Identifier Transcription Error Corpus Generator
Generate synthetic checksum-valid EAN-13 and 978-prefixed ISBN-13 originals, apply a selected decimal substitution, deletion, or adjacent transposition, and record actual GTIN/ISBN validator outcomes; swaps may be unchanged or remain valid, and checksum validity is not product or publication allocation.
- Random JSON Duplicate ID Dataset Generator
Construct linked records with an exact duplicate insertion count and retain missing, unique and ambiguous reference candidate indices.