mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-18 13:21:02 +00:00
Transliterate improvements
This commit is contained in:
parent
df00a0d041
commit
1293c885cc
2 changed files with 7 additions and 16 deletions
|
@ -35,7 +35,6 @@ import android.content.res.Configuration;
|
|||
import android.content.res.Resources;
|
||||
import android.database.sqlite.SQLiteFullException;
|
||||
import android.graphics.Point;
|
||||
import android.icu.text.Transliterator;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
|
@ -100,7 +99,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -1694,14 +1692,9 @@ public class Log {
|
|||
.append(" yes=").append((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0)
|
||||
.append("\r\n");
|
||||
|
||||
if (BuildConfig.DEBUG &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
sb.append("Transliterators:");
|
||||
Enumeration<String> ids = Transliterator.getAvailableIDs();
|
||||
while (ids.hasMoreElements())
|
||||
sb.append(' ').append(ids.nextElement());
|
||||
sb.append("\r\n");
|
||||
}
|
||||
sb.append("Transliterate")
|
||||
.append(TextHelper.canTransliterate())
|
||||
.append("\r\n");
|
||||
|
||||
try {
|
||||
int maxKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength("AES");
|
||||
|
|
|
@ -32,7 +32,6 @@ import android.view.textclassifier.TextClassifier;
|
|||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.text.Normalizer;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
|
@ -47,6 +46,7 @@ import java.util.Set;
|
|||
public class TextHelper {
|
||||
private static final int MAX_SAMPLE_SIZE = 8192;
|
||||
private static final float MIN_PROBABILITY = 0.80f;
|
||||
private static final String TRANSLITERATOR = "Any-Latin; Latin-ASCII";
|
||||
|
||||
static {
|
||||
System.loadLibrary("fairemail");
|
||||
|
@ -95,7 +95,7 @@ public class TextHelper {
|
|||
return false;
|
||||
|
||||
try {
|
||||
Transliterator.getInstance("Any-Latin");
|
||||
Transliterator.getInstance(TRANSLITERATOR);
|
||||
return true;
|
||||
} catch (Throwable ex) {
|
||||
return false;
|
||||
|
@ -112,10 +112,8 @@ public class TextHelper {
|
|||
return text;
|
||||
|
||||
try {
|
||||
Transliterator t = Transliterator.getInstance("Any-Latin");
|
||||
text = t.transliterate(text);
|
||||
String normalized = Normalizer.normalize(text, Normalizer.Form.NFD);
|
||||
text = normalized.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
|
||||
// http://userguide.icu-project.org/transforms/general
|
||||
return Transliterator.getInstance(TRANSLITERATOR).transliterate(text);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue