mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-21 21:57:19 +00:00
Require 10 words for language detection
This commit is contained in:
parent
46922da9f8
commit
aa3f2ee50d
1 changed files with 4 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue