-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add critbit support #20
Comments
Hi there. Thanks for the suggestion. But I'm not sure how this would be useful this would. It also seems to be a heavy dependency to introduce the gem. I'm a bit reluctant to have any JRuby dependencies here too. What do you think? |
Hi Mohamad, Using Critbit would allow the tokenizer to also show all the tokens in [image: Imagem inline 1] I agree that you should not bring any JRuby dependencies to your Gem. My What do you think? Cheers, 2015-10-24 19:37 GMT-02:00 Mohamad El-Husseini notifications@github.com:
Rodrigo Botafogo |
Thanks. I'm having a hard time visualizing what you mean, but that's because I'm not familiar with CritBit. Do you mind sharing a small example of what the interface would look like? Some example, pseudo-code? I've made a few changes to the gem in the last couple of weeks. Are you aware of those changes? I've decoupled the Tokeniser and the Counter classes. |
Hi Mohamad, The Hash API should be a subset of the Critbit API. In principle, wherever crit = Critbit.new add some key, value pairs to critcrit["hello"] = 0 fetch the key from critassert_equal(0, crit.fetch("hello")) remove a key, value pair from crit. Given the key it will returnthe value and remove the entryassert_equal(0, crit.delete("hello")) assert_raise ( KeyError ) { crit.fetch("hello") } crit also accepts complex objectscrit["works?"] = [10, 20, 30] check if keys are stored in critassert_equal(true, crit.has_key?("there")) crit stores data in sorted order, so we can call min and max on critassert_equal(["Essa é uma frase para armazenar", 100], crit.min) crit also allows for checking value containmentassert_equal(true, crit.has_value?(100)) method entries returns all entries in the Critbit... same as Hashassert_equal([["Essa \u00E9 uma frase para armazenar", 100], ["essa", 10], it is possible to change a value for a given keycrit["essa"] = 20 Critbit also allows to get data by prefix. Lets add some data to a Critbit: crit = Critbit.new crit is space efficient and stores prefixes only once and can be used tofind only strings that match a certain prefixitems = ["u", "un", "unh", "uni", "unj", "unim", "unin", "unio", add items to the containeritems.each do |item| Let´s now retrieve only data that has prefix ‘unin’ crit.prefix = "unin" Does each for all elements in the critbit with prefix 'unin'print "[" This is the result: [[unin, unin] [uninc, uninc] [unind, unind] [unindd, unindd] [uninde, Does that help? 2015-10-27 21:35 GMT-02:00 Mohamad El-Husseini notifications@github.com:
Rodrigo Botafogo |
May I suggest that you also use the critbit gem and add words to critbit? In this way you can also do search by prefix.
The text was updated successfully, but these errors were encountered: