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

Don't follow "Did you mean '...'?" redirection #23

Closed
fin0 opened this issue Jul 30, 2022 · 4 comments
Closed

Don't follow "Did you mean '...'?" redirection #23

fin0 opened this issue Jul 30, 2022 · 4 comments

Comments

@fin0
Copy link

fin0 commented Jul 30, 2022

I used linguee-api to search for some translations from English to German and experienced the following problem:
If a word is rare and there is an alternative which is syntactically close and much more frequently used in the language, Linguee offers a "Did you mean '...'?" link at the top of the search results. If this is the case, linguee-api gives the result of the redirection and not the one of the searched word.
Examples (given by the URL linguee-api is querying):
https://www.linguee.com/english-german/search?query=wit&ajax=1
https://www.linguee.com/english-german/search?query=nod&ajax=1

I guess this is not by intention? I don't know, if this behavior occurs on all cases where the result is prefixed with a "Did you mean '...'?" question.

Thanks in advance :)

@imankulov
Copy link
Owner

Oh, thanks for reporting. Great catch!

I implemented automatic following for redirects, assuming that it would only fire on words without translations (mostly typos.) The "wit" case provides a counter-example --- a page having both translations and a suggestion.

It would probably make sense to introduce a new "follow_corrections" option having three variants.

  • follow_corrections=always: Unconditionally follow a correction when finding one. Use it as the default option for backward compatibility.
  • follow_corrections=never: Ignore corrections, and try to parse current text.
  • follow_corrections=on_empty_translations: Parse the result and return if it has translations. If it has no translations, see if there's a correction. If correction is found, follow it.

Does it make sense, @fin0? Please let me know if you have any questions, concerns, or suggestions before I start implementing the follow_corrections flag. Thanks!

@imankulov
Copy link
Owner

Alright, the flag is implemented, as described above. The changes are live on the testing server.

always follow corrections (default and backward-compatible behavior)

before

follow only on empty translations

after

@fin0
Copy link
Author

fin0 commented Aug 7, 2022

Hello @imankulov, wow that was fast! Thanks a lot for your quick response and implementation. Will do further testing once it is merged into master, but everything looks perfect already :)

@imankulov
Copy link
Owner

Hey @fin0, for the record, it's already merged with the master branch.

imankulov added a commit that referenced this issue Oct 9, 2022
The flag defines how to treat responses with a 'did you mean' link.

- `always` (default): always follow the suggestion if found on a page,
   even if the page itself has translations.
- `never`: never follow the suggested correction.
- `on_empty_translations`: only follow the link if there are no
   translations on the page.

Ref: #23
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