{"name":"cspell-trie","version":"8.8.2","keywords":["trie","cspell"],"author":{"name":"Jason Dent"},"license":"MIT","_id":"cspell-trie@8.8.2","homepage":"https://github.com/streetsidesoftware/cspell#readme","bugs":{"url":"https://github.com/streetsidesoftware/cspell/labels/cspell-trie"},"bin":{"cspell-trie":"bin.js"},"dist":{"shasum":"5cb748810545d6a4a7f9459c665636cc1d3b8d44","tarball":"http://registry-npm.ywwl.com/cspell-trie/download/cspell-trie-8.8.2.tgz","fileCount":6,"integrity":"sha512-i1jOWSZRTHF3IBVnHEStdJVkvk/YtXyLmef+YrBuuUisl5WL9UHPCGmMourQwl5vA9WZIF1Vxs/EOkxjXbLx+w==","signatures":[{"sig":"MEUCICFRvroi6cQ3ThUAxZ5PXhPA+TwrBS0u5FDlmEh4v0INAiEArujjJiF7FjR8QEcKQVug0WU/KSbj4QFgbDLIdOYthJ0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9794,"size":4338,"noattachment":false,"key":"/cspell-trie/-/cspell-trie-8.8.2.tgz"},"type":"module","engines":{"node":">=18"},"gitHead":"e82ec807677c040c38b7d5608c8a8d42185d3b24","scripts":{"test":"vitest run","build":"tsc -p .","clean":"shx rm -rf dist temp coverage \"*.tsbuildInfo\"","watch":"tsc -w","coverage":"vitest run --coverage","test-watch":"vitest","clean-build":"pnpm run clean && pnpm run build"},"_npmUser":{"name":"jason-dent","email":"jason@streetsidesoftware.nl"},"repository":{"url":"git+https://github.com/streetsidesoftware/cspell.git","type":"git","directory":"packages/cspell-trie"},"_npmVersion":"lerna/3.4.0/node@v18.20.2+x64 (linux)","description":"Trie Data Structure reader for cspell","directories":{},"sideEffects":false,"_nodeVersion":"18.20.2","dependencies":{"commander":"^12.1.0","gensequence":"^7.0.0","cspell-trie-lib":"8.8.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cspell-trie_8.8.2_1716394302048_0.5720688301769896","host":"s3://npm-registry-packages"},"readme":"# cspell-trie\n\nTrie library for use with cspell\n\nThis library allows easily building of a [Trie](https://en.wikipedia.org/wiki/Trie)\nfrom a word list.\n\nThe resulting trie can then be compressed into a\n[DAFSA|DAWG](https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton).\n\n## Tool\n\n_cspell-trie_ is both a tool and a library.\n\nGive a list of words, _cspell-trie_ will turn it into a _trie_ file.\n\n### Installation\n\n```sh\nnpm install -g cspell-trie\n```\n\n### Usage\n\n```sh\ncspell-trie --help\n```\n\n### Creating a _trie_ file\n\n```sh\ncspell-trie create filename.txt -o filename.trie\n```\n\n### Reading a _trie_ file\n\n```sh\ncspell-trie reader filename.trie\n```\n\n## File Format\n\n### Header\n\n```\nTrieXv1\nbase=10\n```\n\nThe header has two parts.\n\n- TrieXv1 -- the identifiers\n- base -- offsets are stored using the base (10, 16, 32) are common.\n  higher the base, the smaller the file. Max is 36\n\n### Data\n\nThe first line of data is always a `*`\n\nEach line is a node in the Trie.\n\nThe format of each line is:\n\n`star [char index [, char index]*]`\n\n- star - the presence of a star indicates that the node is the ending of a word.\n- char - a character that can be appended to the word followed by the node at index.\n- index - the offset in the list of nodes to continue appending\n\nIn other words, each line has an optional `*` followed by 0 or more (char, index) pairs.\nA missing index implies an index of 0, which is the end of word flag.\n\n**Example Line:** `*s1,e` -- The word can stop here, or add an **s** and continue at node _1_, or add an **e**\n\n### Example:\n\n**Word List:**\n\n- walk\n- walked\n- walker\n- walking\n- walks\n- talk\n- talks\n- talked\n- talker\n- talking\n\nbecomes\n\n**Output:** (Offsets are added for clarity, but do not exist in output)\n\n```text\nOffset  Output\n------- --------\n        TrieXv1\n        base=10\n0       *\n1       d,r\n2       g\n3       n2\n4       *e1,i3,s\n5       k4\n6       l5\n7       a6\n8       t7,w7\n```\n\nThe root of the trie is the last offset, 8.\nIt is designed for the entire trie to be in memory, which is why the root is at the end.\nThis allows for efficiently building the trie as the file loads line by line, because\neach line can only refer to previous lines.\n\nHow to walk the data to see if \"talks\" is in it.\n\n1. Start with the root at offset 8.\n1. t found goto 7\n1. a found goto 6\n1. l found goto 5\n1. k found goto 4\n1. s found stop (goto 0 is stop).\n\n<!---\n    cspell:word DAFSA DAWG\n-->\n\n## CSpell for Enterprise\n\n<!--- @@inject: ../../static/tidelift.md --->\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of cspell and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-cspell?utm_source=npm-cspell&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)\n\n<!--- @@inject-end: ../../static/tidelift.md --->\n\n<!--- @@inject: ../../static/footer.md --->\n\n<br/>\n\n---\n\n<p align=\"center\">Brought to you by<a href=\"https://streetsidesoftware.com\" title=\"Street Side Software\"><img width=\"16\" alt=\"Street Side Software Logo\" src=\"https://i.imgur.com/CyduuVY.png\" /> Street Side Software</a></p>\n\n<!--- @@inject-end: ../../static/footer.md --->\n","publish_time":1716394302228,"maintainers":[{"name":"jason-dent","email":"jason@streetsidesoftware.nl"}],"_cnpm_publish_time":1716394302228,"dist-tags":{"cspell4":"4.2.12","cspell5":"5.21.2","cspell5-next":"5.21.2-alpha.0","latest":"10.4.0","next":"10.4.0-alpha.1"}}