optimization of searching apps in Chinese

Signed-off-by: zhaoguomanong <zhaoguomanong@gmail.com>
Change-Id: Id322eb8b5249d6163da8a5d3476a6cf9500ad6bb
This commit is contained in:
zhaoguomanong
2020-09-10 19:13:02 +08:00
parent 75abb09acd
commit 97cc6df21d
2 changed files with 19 additions and 2 deletions

View File

@@ -81,6 +81,10 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
return false;
}
if (requestSimpleFuzzySearch(query)) {
return title.toLowerCase().contains(query);
}
int lastType;
int thisType = Character.UNASSIGNED;
int nextType = Character.getType(title.codePointAt(0));
@@ -181,4 +185,17 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
return new StringMatcher();
}
}
private static boolean requestSimpleFuzzySearch(String s) {
for (int i = 0; i < s.length(); ) {
int codepoint = s.codePointAt(i);
i += Character.charCount(codepoint);
switch (Character.UnicodeScript.of(codepoint)) {
case HAN:
//Character.UnicodeScript.HAN: use String.contains to match
return true;
}
}
return false;
}
}