[APP-610] Make the language filter more lenient (#562)

* Tune the language filter to accept posts when a determination cant be made

* use j instead of i since i has been declared in upper scope

* use j instead of i since i has been declared in upper scope

* Pass the j man

---------

Co-authored-by: Ansh Nanda <anshnanda10@gmail.com>
zio/stable
Paul Frazee 2023-05-02 20:03:01 -05:00 committed by GitHub
parent ddb8ebb412
commit d225e857b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 2 deletions

View File

@ -203,11 +203,25 @@ export class FeedTuner {
typeof item.post.record.text === 'string'
) {
const res = lande(item.post.record.text)
const contentLangCode3 = res[0][0]
if (langsCode3.includes(contentLangCode3)) {
// require at least 70% confidence; otherwise, roll with it
if (res[0][1] <= 0.7) {
hasPreferredLang = true
break
}
// if the user's languages are in the top 5 guesses, roll with it
for (let j = 0; j < 5 && j < res.length; j++) {
hasPreferredLang =
hasPreferredLang || langsCode3.includes(res[i][0])
}
if (hasPreferredLang) {
break
}
} else {
// no text? roll with it
hasPreferredLang = true
break
}
}
if (!hasPreferredLang) {