Skip to content
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

Return synonym matched for a word #42

Open
charley-earlytracks opened this issue Jul 2, 2024 · 2 comments
Open

Return synonym matched for a word #42

charley-earlytracks opened this issue Jul 2, 2024 · 2 comments

Comments

@charley-earlytracks
Copy link

charley-earlytracks commented Jul 2, 2024

Hello,

It would be useful to be able to retrieve the synonym that was matched for a specific word.

When calling the
autocomplete.search("string", max_cost=2, size=3)
We could add a boolean parameter return_synonym that would allow us to capture the synonym that matched such that we would receive a list of tuple
words_and_synonyms = autocomplete.search("string", max_cost=2, size=3, return_synonym=True)
words_and_synonyms
[("snake","python"), ("programming language", "python"),("framework","pytorch")]

I tried to look into the code to find a way to do it, or even create a whole new autocomplete based only on the synonyms, but it won't always work as the links used are sometimes not the one created using the autocomplete with words and synonyms

@seperman
Copy link
Owner

seperman commented Jul 3, 2024

Hi @charley-earlytracks
We lose the synonym information because we create new "trie" branches for the synonyms from what I recall.

@charley-earlytracks
Copy link
Author

Hey @seperman ,
Thank you for your prompt answer.
I've looked at the code and indeed, you are creating a new Trie branch for the synonyms.
I was just wondering how complex it would be to find the synonym that was matched.

Apart from that, great job with this tool! It works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants