chenkovsky / marisa-trie

Automatically exported from code.google.com/p/marisa-trie
Other
0 stars 0 forks source link

What does id and weight infer in the below union of keyset.h #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What does id and weight infer in the below union of keyset.h

union Union {
    UInt32 id;
    float weight;
  } union_;

Does id mean the id i get when i query marisa trie for a string?
If i put a weight , does the search vary ?
If varies in wht kinds , if there is a prefix and there are 10 word starting 
with that prefix , if weight is set , do i get all the 10 words and i hope i 
get 10 words sorted by weight.Is my interpreatation right?

if i want to use weight , then wht does id convey?
pls respond asap.

Original issue reported on code.google.com by vinay.32...@gmail.com on 9 Dec 2011 at 2:37

GoogleCodeExporter commented 9 years ago
The `weight' is used as an input to marisa::Trie::build().
The `id' is used as an output, where `id' is an ID, as you mentioned.

If you specify weights, the order of a predictive_search() may vary.
But it is just a hint to boost the search performance.
The order of a search result is undefined.
Also note that the `weight' is overwritten with `id' in marisa::Trie::build().

Regards,

Original comment by susumu.y...@gmail.com on 10 Dec 2011 at 12:59

GoogleCodeExporter commented 9 years ago
Thanks for the reply.
I want to use weight for a purpose of storing an extra info for every
string may be frequency of every string .so can I do that.if I do that does
Id value get invalid.
Suppose if I'm not using weight ,I query for a string to marisa true,say I
get 10 results .and now if I build marisa trie without weight and then I
query for the same thing,I will get all the 10 entries right .?
 On 10-Dec-2011 6:30 AM, <marisa-trie@googlecode.com> wrote:

Original comment by vinay.32...@gmail.com on 10 Dec 2011 at 4:31

GoogleCodeExporter commented 9 years ago
Weights are not available after marisa::Trie::build(), because they are used 
and then discarded. If you want to keep weights associated with keys, like 
values in a key-value store, please store the weights into an extra array. You 
can get key IDs from the keyset.

If you don't give weights, marisa-trie uses the default weight (1.0). So, the 
result does not change. But please note that the order may change.

Original comment by susumu.y...@gmail.com on 10 Dec 2011 at 2:18

GoogleCodeExporter commented 9 years ago

Original comment by susumu.y...@gmail.com on 28 Feb 2012 at 12:19