Fix Den Ilp search

This commit is contained in:
Victor Shcherb 2016-08-10 22:50:16 +02:00
parent 70c694f3bc
commit 9d8a2b6535

View file

@ -6,6 +6,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -41,6 +42,28 @@ public class SearchPhrase {
private static final Pattern reg = Pattern.compile(ALLDELIMITERS); private static final Pattern reg = Pattern.compile(ALLDELIMITERS);
private Collator clt; private Collator clt;
private static Set<String> conjunctionsThe = new TreeSet<>();
private static Set<String> conjunctionsAnd = new TreeSet<>();
static {
// the
conjunctionsThe.add("the");
conjunctionsThe.add("der");
conjunctionsThe.add("den");
conjunctionsThe.add("die");
conjunctionsThe.add("das");
conjunctionsThe.add("la");
conjunctionsThe.add("le");
conjunctionsThe.add("el");
conjunctionsThe.add("il");
// and
conjunctionsAnd .add("and");
conjunctionsAnd .add("und");
conjunctionsAnd .add("en");
conjunctionsAnd .add("et");
conjunctionsAnd .add("y");
conjunctionsAnd .add("и");
}
public enum SearchPhraseDataType { public enum SearchPhraseDataType {
MAP, ADDRESS, ROUTING, POI MAP, ADDRESS, ROUTING, POI
@ -84,11 +107,13 @@ public class SearchPhrase {
} else { } else {
sp.unknownSearchWordTrim = ""; sp.unknownSearchWordTrim = "";
String[] ws = restText.split(ALLDELIMITERS); String[] ws = restText.split(ALLDELIMITERS);
boolean first = true;
for (int i = 0; i < ws.length ; i++) { for (int i = 0; i < ws.length ; i++) {
String wd = ws[i].trim(); String wd = ws[i].trim();
if (wd.length() > 0) { if (wd.length() > 0 && !conjunctionsThe.contains(wd.toLowerCase())) {
if (i == 0) { if (first) {
sp.unknownSearchWordTrim = wd; sp.unknownSearchWordTrim = wd;
first = false;
} else { } else {
sp.unknownWords.add(wd); sp.unknownWords.add(wd);
} }