Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Paul Frazee
Ansh Nanda
and committed by
GitHub
d225e857 ddb8ebb4

+16 -2
+16 -2
src/lib/api/feed-manip.ts
··· 203 203 typeof item.post.record.text === 'string' 204 204 ) { 205 205 const res = lande(item.post.record.text) 206 - const contentLangCode3 = res[0][0] 207 - if (langsCode3.includes(contentLangCode3)) { 206 + 207 + // require at least 70% confidence; otherwise, roll with it 208 + if (res[0][1] <= 0.7) { 208 209 hasPreferredLang = true 209 210 break 210 211 } 212 + 213 + // if the user's languages are in the top 5 guesses, roll with it 214 + for (let j = 0; j < 5 && j < res.length; j++) { 215 + hasPreferredLang = 216 + hasPreferredLang || langsCode3.includes(res[i][0]) 217 + } 218 + if (hasPreferredLang) { 219 + break 220 + } 221 + } else { 222 + // no text? roll with it 223 + hasPreferredLang = true 224 + break 211 225 } 212 226 } 213 227 if (!hasPreferredLang) {