tournesol-app / tournesol

Free and open source code of the https://tournesol.app platform. Meet the community on Discord https://discord.gg/WvcSG55Bf3
https://tournesol.app
Other
334 stars 48 forks source link

[back] feat: ClassicEntitySuggestionStrategy should use the user's preferred languages when returning recommended entities #1834

Closed GresilleSiffle closed 7 months ago

GresilleSiffle commented 1 year ago

The suggestion strategy ClassicEntitySuggestionStrategy can include in its results entities from the recent and all-time recommendations.

The recommendations should be returned according to the user's preferred languages configured in its setting recommendations__default_languages (if the poll has such a notion, not all polls have a language associated with their entities).

pending questions

(a) What should we return when the user hasn't defined its preferred languages?

(b) What should the strategy do when no recommendations are available in the user's preferred languages?

GresilleSiffle commented 1 year ago

I moved this issue in the selected column because it's the continuation of a pull request that is about to be merged.

Feel free to move back this issue in the Idea column in case of need.

GresilleSiffle commented 7 months ago

The way it has been implemented in #1961 has a small issue.

The recommended entities, which represent 4 / 20 of entities recommended by the ClassicEntitySuggestionStrategy, are randomly selected. If a user has en and it defined as his/her preferred languages, the suggestions will contain mostly in English recommendations, because the API database has far more English entities than Italian. In fact, it's possible that the user will get zero entities matching the Italian language.

This is even more problematic for a user having only it defined as his/her preferred language. The view always adds en to the preferred languages if they don't contain en or fr, and it's possible that this user will get only English recommendations even if the database contain enough recommendations in Italian.

I think the issue is small because:

This could be fixed by adding a "fallback" feature in the ClassicEntitySuggestionStrategy class. Instead of returning recommended entities based on a single list of languages, the class could:

edit as discussed with @amatissart , another "fix" could be simply to add the languages that are represented by enough entities to the list SuggestionsToCompare.min_lang_set, see:

https://github.com/tournesol-app/tournesol/blob/c0c5c3df922c0378c33b2d93d810834ab3eb9f0f/backend/tournesol/views/suggestions/to_compare.py#L48