about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/lib/api/feed-manip.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts
index 2429419d8..341e8727d 100644
--- a/src/lib/api/feed-manip.ts
+++ b/src/lib/api/feed-manip.ts
@@ -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) {