Dushistov / sdcv

https://dushistov.github.io/sdcv/
GNU General Public License v2.0
289 stars 42 forks source link

lookup: do not bail on first failed lookup with a word list #77

Closed cyphar closed 2 years ago

cyphar commented 2 years ago

Due to the lack of deinflection support in StarDict, users might want to be able to create a list of possible deinflections and search each one to see if there is a dictionary entry for that deinflection.

Being able to do this in one sdcv invocation is far more preferable to calling sdcv once for each candidate due to the performance cost of doing so. The most obvious language that would benefit from this is Japanese, but I'm sure other folks would prefer this.

In order to make this use-case better supported -- try to look up every word in the provided list of words before existing with an error if any one of the words failed to be looked up.

Signed-off-by: Aleksa Sarai cyphar@cyphar.com

cyphar commented 2 years ago

To be honest, I'm not sure that returning an error if only one of the words failed to be looked up is preferable (it depends on what the user wants -- for the Japanese use-case if any one of the candidate words was correctly found that's a success), but I've kept the same error returning behaviour as before just in case.

cyphar commented 2 years ago

Added a test to tests/t_json.

cyphar commented 2 years ago

/ping @Dushistov

This is a feature which is needed for KoReader to get language-specific plugin support (specifically Japanese but it would be needed for a few other languages where you need to be able to efficiently look up multiple candidate words at the same time).

Dushistov commented 2 years ago

Thanks for PR. I am little busy now, but I will test PR at the end of this week.

cyphar commented 2 years ago

Thanks. :smile_cat: