Fix compilation problems
This commit is contained in:
parent
f40657ebec
commit
c52054dadc
5 changed files with 37 additions and 53 deletions
|
@ -25,9 +25,6 @@ public class CollatorStringMatcher implements StringMatcher {
|
||||||
CHECK_STARTS_FROM_SPACE_NOT_BEGINNING,
|
CHECK_STARTS_FROM_SPACE_NOT_BEGINNING,
|
||||||
// tests all words (split by space) and one of word should be equal to part
|
// tests all words (split by space) and one of word should be equal to part
|
||||||
CHECK_EQUALS_FROM_SPACE,
|
CHECK_EQUALS_FROM_SPACE,
|
||||||
// TO DO: make a separate method
|
|
||||||
// trims part to make shorter then full text and tests only first word as base starts with part
|
|
||||||
TRIM_AND_CHECK_ONLY_STARTS_WITH,
|
|
||||||
// simple collator contains in any part of the base
|
// simple collator contains in any part of the base
|
||||||
CHECK_CONTAINS,
|
CHECK_CONTAINS,
|
||||||
// simple collator equals
|
// simple collator equals
|
||||||
|
@ -62,11 +59,6 @@ public class CollatorStringMatcher implements StringMatcher {
|
||||||
return cstartsWith(collator, fullName, part, false, true, false);
|
return cstartsWith(collator, fullName, part, false, true, false);
|
||||||
case CHECK_ONLY_STARTS_WITH:
|
case CHECK_ONLY_STARTS_WITH:
|
||||||
return cstartsWith(collator, fullName, part, true, false, false);
|
return cstartsWith(collator, fullName, part, true, false, false);
|
||||||
case TRIM_AND_CHECK_ONLY_STARTS_WITH:
|
|
||||||
if (part.length() > fullName.length()) {
|
|
||||||
part = part.substring(0, fullName.length());
|
|
||||||
}
|
|
||||||
return cstartsWith(collator, fullName, part, true, false, false);
|
|
||||||
case CHECK_EQUALS:
|
case CHECK_EQUALS:
|
||||||
return cstartsWith(collator, fullName, part, false, false, true);
|
return cstartsWith(collator, fullName, part, false, false, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class SearchUICore {
|
||||||
taskQueue = new LinkedBlockingQueue<Runnable>();
|
taskQueue = new LinkedBlockingQueue<Runnable>();
|
||||||
searchSettings = new SearchSettings(new ArrayList<BinaryMapIndexReader>());
|
searchSettings = new SearchSettings(new ArrayList<BinaryMapIndexReader>());
|
||||||
searchSettings = searchSettings.setLang(locale, transliterate);
|
searchSettings = searchSettings.setLang(locale, transliterate);
|
||||||
phrase = SearchPhrase.emptyPhrase();
|
phrase = SearchPhrase.emptyPhrase(searchSettings);
|
||||||
currentSearchResult = new SearchResultCollection(phrase);
|
currentSearchResult = new SearchResultCollection(phrase);
|
||||||
singleThreadedExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, taskQueue);
|
singleThreadedExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, taskQueue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,6 @@ import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class SearchCoreFactory {
|
public class SearchCoreFactory {
|
||||||
|
|
||||||
|
@ -678,7 +676,7 @@ public class SearchCoreFactory {
|
||||||
@Override
|
@Override
|
||||||
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
|
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
|
||||||
boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent();
|
boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent();
|
||||||
NameStringMatcher nm = phrase.getFullUnknownNameMatcher();
|
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
|
||||||
initPoiTypes();
|
initPoiTypes();
|
||||||
List<AbstractPoiType> poiTypes = topVisibleFilters;
|
List<AbstractPoiType> poiTypes = topVisibleFilters;
|
||||||
if (!showTopFiltersOnly) {
|
if (!showTopFiltersOnly) {
|
||||||
|
@ -818,18 +816,18 @@ public class SearchCoreFactory {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
} else if (searchAmenityTypesAPI != null) {
|
} else if (searchAmenityTypesAPI != null) {
|
||||||
NameStringMatcher nm = phrase.getFullUnknownNameMatcher();
|
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
|
||||||
searchAmenityTypesAPI.initPoiTypes();
|
searchAmenityTypesAPI.initPoiTypes();
|
||||||
List<AbstractPoiType> presentPoiTypes = searchAmenityTypesAPI.getPoiTypeResults(nm, false);
|
List<AbstractPoiType> presentPoiTypes = searchAmenityTypesAPI.getPoiTypeResults(nm, false);
|
||||||
// TODO get first ?
|
// TODO get first ? !!!
|
||||||
AbstractPoiType poiType = phrase.getUnknownSearchWordPoiType();
|
// AbstractPoiType poiType = phrase.getUnknownSearchWordPoiType();
|
||||||
if (poiType != null) {
|
// if (poiType != null) {
|
||||||
poiTypeFilter = getPoiTypeFilter(poiType);
|
// poiTypeFilter = getPoiTypeFilter(poiType);
|
||||||
nameFilter = phrase.getPoiNameFilter(poiType);
|
// nameFilter = phrase.getPoiNameFilter(poiType);
|
||||||
if (nameFilter != null) {
|
// if (nameFilter != null) {
|
||||||
phrase.setUnknownSearchWordPoiType(poiType);
|
// phrase.setUnknownSearchWordPoiType(poiType);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
if (poiTypeFilter != null) {
|
if (poiTypeFilter != null) {
|
||||||
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS);
|
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS);
|
||||||
|
@ -853,7 +851,7 @@ public class SearchCoreFactory {
|
||||||
private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchResultMatcher resultMatcher,
|
private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchResultMatcher resultMatcher,
|
||||||
final String nameFilter, final BinaryMapIndexReader selected,
|
final String nameFilter, final BinaryMapIndexReader selected,
|
||||||
final Set<String> searchedPois) {
|
final Set<String> searchedPois) {
|
||||||
// TODO
|
// TODO !!!
|
||||||
// String unknownSearchPhrase = phrase.getUnknownSearchPhrase().trim();
|
// String unknownSearchPhrase = phrase.getUnknownSearchPhrase().trim();
|
||||||
// final NameStringMatcher phraseMatcher;
|
// final NameStringMatcher phraseMatcher;
|
||||||
// if (!Algorithms.isEmpty(unknownSearchPhrase)) {
|
// if (!Algorithms.isEmpty(unknownSearchPhrase)) {
|
||||||
|
@ -861,13 +859,14 @@ public class SearchCoreFactory {
|
||||||
// } else {
|
// } else {
|
||||||
// phraseMatcher = null;
|
// phraseMatcher = null;
|
||||||
// }
|
// }
|
||||||
final NameStringMatcher ns;
|
// final NameStringMatcher ns;
|
||||||
final boolean hasCustomName = !Algorithms.isEmpty(nameFilter);
|
// final boolean hasCustomName = !Algorithms.isEmpty(nameFilter);
|
||||||
if (hasCustomName) {
|
// if (hasCustomName) {
|
||||||
ns = phrase.getNameStringMatcher(nameFilter, phrase.isLastUnknownSearchWordComplete());
|
// ns = phrase.getNameStringMatcher(nameFilter, phrase.isLastUnknownSearchWordComplete());
|
||||||
} else {
|
// } else {
|
||||||
ns = phrase.getFirstUnknownNameStringMatcher();
|
// ns = phrase.getFirstUnknownNameStringMatcher();
|
||||||
}
|
// }
|
||||||
|
NameStringMatcher ns = phrase.getFirstUnknownNameStringMatcher();
|
||||||
return new ResultMatcher<Amenity>() {
|
return new ResultMatcher<Amenity>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -914,16 +913,17 @@ public class SearchCoreFactory {
|
||||||
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
||||||
res.priorityDistance = 1;
|
res.priorityDistance = 1;
|
||||||
|
|
||||||
if (phraseMatcher != null) {
|
// TODO !!!
|
||||||
boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName);
|
// if (phraseMatcher != null) {
|
||||||
AbstractPoiType unknownSearchWordPoiType = phrase.getUnknownSearchWordPoiType();
|
// boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName);
|
||||||
if (unknownPhraseMatches && unknownSearchWordPoiType != null) {
|
// AbstractPoiType unknownSearchWordPoiType = phrase.getUnknownSearchWordPoiType();
|
||||||
unknownPhraseMatches = !phraseMatcher.matches(unknownSearchWordPoiType.getTranslation())
|
// if (unknownPhraseMatches && unknownSearchWordPoiType != null) {
|
||||||
&& !phraseMatcher.matches(unknownSearchWordPoiType.getEnTranslation())
|
// unknownPhraseMatches = !phraseMatcher.matches(unknownSearchWordPoiType.getTranslation())
|
||||||
&& !phraseMatcher.matches(unknownSearchWordPoiType.getSynonyms());
|
// && !phraseMatcher.matches(unknownSearchWordPoiType.getEnTranslation())
|
||||||
}
|
// && !phraseMatcher.matches(unknownSearchWordPoiType.getSynonyms());
|
||||||
res.unknownPhraseMatches = unknownPhraseMatches;
|
// }
|
||||||
}
|
// res.unknownPhraseMatches = unknownPhraseMatches;
|
||||||
|
// }
|
||||||
res.objectType = ObjectType.POI;
|
res.objectType = ObjectType.POI;
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -293,15 +293,6 @@ public class SearchPhrase {
|
||||||
return lastUnknownSearchWordComplete;
|
return lastUnknownSearchWordComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NameStringMatcher getFullUnknownNameMatcher() {
|
|
||||||
// TODO investigate diesel 95
|
|
||||||
if (isLastUnknownSearchWordComplete() || hasMoreThanOneUnknownSearchWord()) {
|
|
||||||
return new NameStringMatcher(unknownSearchPhrase, StringMatcherMode.TRIM_AND_CHECK_ONLY_STARTS_WITH);
|
|
||||||
} else {
|
|
||||||
return new NameStringMatcher(unknownSearchPhrase, StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasMoreThanOneUnknownSearchWord() {
|
public boolean hasMoreThanOneUnknownSearchWord() {
|
||||||
return otherUnknownWords.size() > 0;
|
return otherUnknownWords.size() > 0;
|
||||||
}
|
}
|
||||||
|
@ -534,7 +525,7 @@ public class SearchPhrase {
|
||||||
|
|
||||||
public NameStringMatcher getUnknownNameStringMatcher(int i) {
|
public NameStringMatcher getUnknownNameStringMatcher(int i) {
|
||||||
while (unknownWordsMatcher.size() <= i) {
|
while (unknownWordsMatcher.size() <= i) {
|
||||||
int ind = unknownWordsMatcher.size() - 1;
|
int ind = unknownWordsMatcher.size();
|
||||||
boolean completeMatch = ind < otherUnknownWords.size() - 1 || isLastUnknownSearchWordComplete();
|
boolean completeMatch = ind < otherUnknownWords.size() - 1 || isLastUnknownSearchWordComplete();
|
||||||
unknownWordsMatcher.add(getNameStringMatcher(otherUnknownWords.get(ind), completeMatch));
|
unknownWordsMatcher.add(getNameStringMatcher(otherUnknownWords.get(ind), completeMatch));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,15 @@ public class SearchResult {
|
||||||
res = ObjectType.getTypeWeight(objectType);
|
res = ObjectType.getTypeWeight(objectType);
|
||||||
}
|
}
|
||||||
if (parentSearchResult != null) {
|
if (parentSearchResult != null) {
|
||||||
// TODO
|
|
||||||
// 10 > maximum type
|
|
||||||
// double x = parentSearchResult.getUnknownPhraseMatchWeight();
|
// double x = parentSearchResult.getUnknownPhraseMatchWeight();
|
||||||
// if (x == 0) {
|
// if (x == 0) {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
// res = Math.max(res, parentSearchResult.getUnknownPhraseMatchWeight());
|
// res = Math.max(res, parentSearchResult.getUnknownPhraseMatchWeight());
|
||||||
res += parentSearchResult.getUnknownPhraseMatchWeight() / 10;
|
// res += parentSearchResult.getUnknownPhraseMatchWeight() / 10;
|
||||||
|
// 20 > maximum type
|
||||||
|
// TODO explain comment
|
||||||
|
res = res / 20 + parentSearchResult.getUnknownPhraseMatchWeight() / 20;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue