GithubHelp home page GithubHelp logo

indiesquidge / autocomplete Goto Github PK

View Code? Open in Web Editor NEW
5.0 0.0 0.0 30 KB

low-level, primitive autocomplete using trie data structure

License: MIT License

JavaScript 100.00%
javascript trie-tree-autocomplete trie-structure autocomplete

autocomplete's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

autocomplete's Issues

Requesting to delete a word throws unexpected error

Requesting to delete a word with some matching prefix to an existing word throws a useful error

const completion = createTrie()

completion.insert('list')
completion.delete('lis') // throws `Error: foo is not a word, nothing deleted`

But if I request to delete a word with no matching prefix to an existing word, the error thrown is not helpful

const completion = createTrie()

completion.delete('foo') // throws `TypeError: Cannot read property 'getIsCompleteString' of undefined`

I would expect the latter snippet to throw the same error as the former snippet.

Suggestions include query when they shouldn't

If my query includes an inserted word as a prefix, it includes my query in the list of suggestions.

If my query starts with the same letter as an inserted word, I get a strange suggestion that appears to be the merging of the query and the inserted word.

const completion = createTrie();

completion.suggest("listening"); // should be [], got []
completion.insert("list");
completion.suggest("listening"); // should still be [], got ["listening"]
completion.suggest("lost"); // should still be [], got ["lostist"] (!!!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.