s-yata / marisa-trie

MARISA: Matching Algorithm with Recursively Implemented StorAge
Other
506 stars 89 forks source link

can marisa-build preserves the original weight of a special key? #15

Closed dongyuwei closed 5 years ago

dongyuwei commented 6 years ago

hi @s-yata Thank you for your excellent marisa-trie.

I have a question, hope you can give some help or hint: The document on http://s-yata.github.io/marisa-trie/docs/readme.en.html has this description:

If an input line contains horizontal tabs, the last one serves as the delimiter between a key and its weight which is used to optimize the order of nodes. Estimated frequency of each key, given as the weight, may improve the search performance.

I'm wonder if marisa-trie can keep the original predefined weight of a special key? I mean not the updated weight.

while (trie.predictive_search(agent)) {
    const marisa::Key key = agent.key();
    key.weight(); // this `weight` is not the original weight
}

Can marisa-trie provide another api to get the original predefined weight? That will be very helpful for many use-cases, eg: a word with predefined frequency as the weight in a large words dictionary.

s-yata commented 5 years ago

marisa-trie uses the weights to arrange trie nodes for optimization and does not keep the weights.

It requires much memory to keep the weights, and thus marisa-trie does not keep.

dongyuwei commented 5 years ago

Okay, thank you for your reply.