A console-based autocomplete application built with JavaScript and a Trie data structure.
The app allows users to add words, search for words, and get autocomplete suggestions based on a prefix. Suggestions are ranked by word usage frequency.
- Add words to the dictionary
- Find if a word exists
- Get autocomplete suggestions by prefix
- Track word usage frequency
- Rank suggestions by frequency
- Console-based interface
- Unit tests with Jest
add <word> Add a word to the dictionary
find <word> Check if a word exists
complete <prefix> Show autocomplete suggestions
use <word> Increase word usage frequency
help Show available commands
exit Quit the program> add cat
✓ Added 'cat' to dictionary
> add car
✓ Added 'car' to dictionary
> complete ca
Suggestions for 'ca': cat (0), car (0)
> use cat
✓ Incremented usage for 'cat' (now 1)
> complete ca
Suggestions for 'ca': cat (1), car (0)
> find dog
✗ 'dog' not found in dictionarynpm installnode src/CLI/index.jsnpm testRun tests with coverage:
npm test -- --coverageThe project was built with a clear separation of responsibilities, inspired by an MVC-style structure:
Handles the core Trie logic, including adding words, searching words, autocomplete suggestions, and word frequency.
Handles user commands and connects the console input to the Trie logic.
Handles the console output shown to the user.
- Add a web UI
- Save words to a file or database
- Add delete word option
- Add more tests for the controller and console view
Daniel Chernov