Use right range and threshold for showing "bad" words/sentences (#370)

* Use ln(0.5) as the threshold
* Use right range for showing "bad" words/sentences
This commit is contained in:
Abhishek Aggarwal 2022-03-03 17:24:32 +01:00 committed by GitHub
parent 1360941ab9
commit 89a96bf71e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,13 +59,13 @@ const addQualityClasses = (root) => {
// You can do this wit CSS variables, calc() and min/max, but JS is just easier
root.querySelectorAll('[x-bergamot-sentence-score]').forEach(el => {
// Note: these thresholds are just examples, they are not good thresholds!
el.classList.toggle('bad', parseFloat(el.getAttribute('x-bergamot-sentence-score')) > -0.1);
// The threshold is ln(0.5) (https://github.com/browsermt/bergamot-translator/pull/370#issuecomment-1058123399)
el.classList.toggle('bad', parseFloat(el.getAttribute('x-bergamot-sentence-score')) < -0.6931);
});
root.querySelectorAll('[x-bergamot-word-score]').forEach(el => {
// Note: these thresholds are just examples, they are not good thresholds!
el.classList.toggle('bad', parseFloat(el.getAttribute('x-bergamot-word-score')) > -0.1);
// The threshold is ln(0.5) (https://github.com/browsermt/bergamot-translator/pull/370#issuecomment-1058123399)
el.classList.toggle('bad', parseFloat(el.getAttribute('x-bergamot-word-score')) < -0.6931);
});
// Add tooltips to each (sub)word with sentence and word score.