Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryandotsmith/triehouse
a trie data structure (foudation for a more robust auto-complete search)
https://github.com/ryandotsmith/triehouse
Last synced: about 2 months ago
JSON representation
a trie data structure (foudation for a more robust auto-complete search)
- Host: GitHub
- URL: https://github.com/ryandotsmith/triehouse
- Owner: ryandotsmith
- Created: 2010-04-18T15:07:45.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2010-05-06T02:41:57.000Z (over 14 years ago)
- Last Synced: 2024-10-13T17:47:19.616Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Trie House
This is a trie data structure implemented in ruby. The goal for the project was purely academic. However, I am thinking that something like this might be useful for an auto-complete plugin.
I would like to see if there is a way to bypass AR for auto-complete queries. Ideally, i would have the data returned from the query populated into the trie.
trie = Trie.new
trie << "pie" << "apple" << "baseball"
trie.has_word?("p") #=> true
trie.has_word?("pi") #=> true
trie.has_word?("pie") #=> true
trie.each { |word| puts word.key }
trie = Trie.new
trie << 'one' << 'only' << 'on'
trie.suggests('o') #=> ['on','only','one']