mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 06:08:31 +02:00
Require 10 words for language detection
This commit is contained in:
@@ -60,6 +60,7 @@ import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
public class TextHelper {
|
||||
private static final int MIN_WORDS = 10;
|
||||
private static final int MAX_DETECT_SAMPLE_SIZE = 8192;
|
||||
private static final float MIN_DETECT_PROBABILITY = 0.80f;
|
||||
private static final String TRANSLITERATOR = "Any-Latin; Latin-ASCII";
|
||||
@@ -82,6 +83,9 @@ public class TextHelper {
|
||||
if (TextUtils.isEmpty(text))
|
||||
return null;
|
||||
|
||||
if (text.split("\\s+").length < MIN_WORDS)
|
||||
return null;
|
||||
|
||||
byte[] octets = text.getBytes();
|
||||
byte[] sample;
|
||||
if (octets.length < MAX_DETECT_SAMPLE_SIZE)
|
||||
|
||||
Reference in New Issue
Block a user