Ron89 / thesaurus_query.vim

Multi-language Thesaurus Query and Replacement plugin for Vim/NeoVim
http://www.vim.org/scripts/script.php?script_id=5341
Apache License 2.0
220 stars 23 forks source link

Is the lookup in mthesaur all words in the line or only first? #55

Closed barskern closed 1 year ago

barskern commented 1 year ago

When the plugin searches for synonyms it returns the first line which contains the word that is queried (see snippet).

https://github.com/Ron89/thesaurus_query.vim/blob/23d8aa3f7d1a785e31e760e1b6b3b4c18abf8332/autoload/thesaurus_query/backends/mthesaur_lookup.py#L33

The way I understood the format of mthesaur is that the "root" word is the first word of the line, so shouldn't this line then be changed to:

if word == synonym_list[0]:

The reason I'm posing the question is that I seem to get a lot of "bad" synonyms when I query a word, normally because the word appears in a synonym list of another word where the link is debatable.

Ron89 commented 1 year ago

Hi @barskern , mthesaur organizes groups of words with similar meanings. So the target word may not be the first word in the word list.

Then again, a single word may have many meanings. So technically a word may appear in multiple rows instead of one. Looking at the logic now, this function only retrieve the synonym of a word for its first appearing meaning group.

Since this thesaurus plugin already support multiple meaning groups, let me change its logic to include all its meaning groups.

Ron89 commented 1 year ago

@barskern , I have made the change, though... the result is for common words with a lot of meaning groups, the result can be horrendously huge.

In the plugin, we have two parameters that may reduce the pain of overly abundant result, g:tq_truncation_on_definition_num and g:tq_truncation_on_syno_list_size.

https://github.com/Ron89/thesaurus_query.vim/blob/2bb83fa7c27038baee875d42af445c20fbe09b59/doc/thesaurus_query.txt#L252-L269

For example, if you use

let g:tq_truncation_on_definition_num = 10
let g:tq_truncation_on_syno_list_size = 20

the number of returned value will be much more manageable, though there is risk that some useful results are filtered out. Unfortunately, mthesaur does not rank results by relevance.

barskern commented 1 year ago

@Ron89 That was quick feedback, thank you so much. I will give it a go with the changes you implemented here, though the immense amount of suggestions that you outline seem to make this backend quite difficult to use and benefit from. I might simply continue to only use the datamuse_com backend, as it gives good answer, though few to choose from.

Ron89 commented 1 year ago

Since there is no further update for a few months, I will close this ticket for now.