Fix #9529
This commit is contained in:
parent
0a77312535
commit
7b10a094ef
2 changed files with 25 additions and 1 deletions
|
@ -160,7 +160,7 @@ public class SearchPhrase {
|
|||
|
||||
|
||||
public SearchPhrase generateNewPhrase(String text, SearchSettings settings) {
|
||||
String textToSearch = text;
|
||||
String textToSearch = Algorithms.normalizeSearchText(text);
|
||||
List<SearchWord> leftWords = this.words;
|
||||
String thisTxt = getText(true);
|
||||
List<SearchWord> foundWords = new ArrayList<>();
|
||||
|
@ -183,6 +183,7 @@ public class SearchPhrase {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static SearchPhrase emptyPhrase() {
|
||||
return emptyPhrase(null);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,29 @@ public class Algorithms {
|
|||
public static boolean isEmpty(Collection<?> c) {
|
||||
return c == null || c.size() == 0;
|
||||
}
|
||||
|
||||
private static char[] CHARS_TO_NORMALIZE_KEY = new char['’'];
|
||||
private static char[] CHARS_TO_NORMALIZE_VALUE = new char['\''];
|
||||
|
||||
public static String normalizeSearchText(String s) {
|
||||
boolean norm = false;
|
||||
for (int i = 0; i < s.length() && !norm; i++) {
|
||||
char ch = s.charAt(i);
|
||||
for (int j = 0; j < CHARS_TO_NORMALIZE_KEY.length; j++) {
|
||||
if (ch == CHARS_TO_NORMALIZE_KEY[j]) {
|
||||
norm = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!norm) {
|
||||
return s;
|
||||
}
|
||||
for (int k = 0; k < CHARS_TO_NORMALIZE_KEY.length; k++) {
|
||||
s = s.replace(CHARS_TO_NORMALIZE_KEY[k], CHARS_TO_NORMALIZE_VALUE[k]);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return map == null || map.size() == 0;
|
||||
|
|
Loading…
Reference in a new issue