Project

General

Profile

Feature #16932

Feature #10034: Translation web platform

Weblate staging website: improve algorithm that chooses among available suggestions

Added by intrigeri about 2 months ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Infrastructure
Target version:
-
Start date:
Due date:
% Done:

0%

Feature Branch:
salsa.debian.org:/hefee/puppet-tails.git:hefee/16932-most-voted-suggestion
Type of work:
Code
Blueprint:
Starter:
Affected tool:
Translation Platform

Description

According to drebs' research on #11763#note-31, files/weblate/scripts/save-suggestions.py (in the puppet-tails.git repo) currently picks the oldest suggestion. Instead we would like to:

  • Pick the suggestion with most number of votes.
  • If there are several suggestions with the largest number of votes, then pick the newest one.

Related issues

Related to Tails - Bug #16989: Enable voting for Weblate users Resolved

History

#1 Updated by intrigeri about 2 months ago

@hefee, can you easily tell us how expensive this would be to implement?

#2 Updated by intrigeri about 2 months ago

  • If there are several suggestions with the largest number of votes, then pick the newest one.

drebs and I have tried to implement this with https://git-tails.immerda.ch/puppet-tails/commit/?id=afacf5d62f7b112a1070ed472c84ae675c24c3c7 and have prepared a test string with several suggestions (in wiki/src/sandbox.fr.po). Now building the staging website, will report back once we can see the output.

#3 Updated by intrigeri about 2 months ago

intrigeri wrote:

  • If there are several suggestions with the largest number of votes, then pick the newest one.

drebs and I have tried to implement this with https://git-tails.immerda.ch/puppet-tails/commit/?id=afacf5d62f7b112a1070ed472c84ae675c24c3c7 and have prepared a test string with several suggestions (in wiki/src/sandbox.fr.po). Now building the staging website, will report back once we can see the output.

It worked! :)

So the only remaining thing to evaluate here is "Pick the suggestion with most number of votes" (and only fall back to date comparison to disentangle equality there).

#4 Updated by hefee about 1 month ago

It should be quite simple to implement this. I expect something like 10-15min. It should be something like this. But I havn't tested it yet. Maybe we need reverse=True, as parameters for sort or replace next() with list()[0] or list()[-1]:

--- a/files/weblate/scripts/save-suggestions.py
+++ b/files/weblate/scripts/save-suggestions.py
@@ -64,7 +64,9 @@ for i in range(len_subprojects):
         for translation in subproject.translation_set.all():
             for unit in translation.unit_set.all():
                 if unit.suggestions:
-                    s = list(unit.suggestions)[0]
+                    # Get most voted suggestion
+                    date_sorted = sorted(unit.suggestions, key=lambda i: i.timestamp))
+                    s = next(sorted(date_sorted, key=lambda i: i.get_num_votes()))
                     logger.debug("found suggestion for %s", unit)
                     # weblate/trans/models/translations.py: update_units
                     src = unit.get_source_plurals()[0]

#5 Updated by hefee about 1 month ago

  • Status changed from Confirmed to Needs Validation
  • Assignee set to intrigeri
  • Feature Branch set to salsa.debian.org:/hefee/puppet-tails.git:hefee/16932-most-voted-suggestion

I tested it for wiki/src/sandbox.de.po and checked that the fist translation unit is corrected set to "Dies ist ein Sandkasten. XX" (most voted suggestion)

I enabled suggestion_voting=True for the wiki/src/sandbox for this test and currently we need reviewer privileges to vote. In order to use voting in production, we need to enable votes for every user.

#6 Updated by intrigeri about 1 month ago

  • Status changed from Needs Validation to Resolved

Deployed!

I enabled suggestion_voting=True for the wiki/src/sandbox for this test and currently we need reviewer privileges to vote. In order to use voting in production, we need to enable votes for every user.

OK, if you feel the current state of things is not good enough, please raise this in the discussion about workflows/permissions.

#7 Updated by hefee about 1 month ago

  • Related to Bug #16989: Enable voting for Weblate users added

Also available in: Atom PDF