Fix compilation problems

This commit is contained in:
Victor Shcherb 2020-06-02 00:34:41 +02:00
parent f40657ebec
commit c52054dadc
5 changed files with 37 additions and 53 deletions

View file

@ -25,9 +25,6 @@ public class CollatorStringMatcher implements StringMatcher {
CHECK_STARTS_FROM_SPACE_NOT_BEGINNING,
// tests all words (split by space) and one of word should be equal to part
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
CHECK_CONTAINS,
// simple collator equals
@ -62,11 +59,6 @@ public class CollatorStringMatcher implements StringMatcher {
return cstartsWith(collator, fullName, part, false, true, false);
case CHECK_ONLY_STARTS_WITH:
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:
return cstartsWith(collator, fullName, part, false, false, true);
}

View file

@ -71,7 +71,7 @@ public class SearchUICore {
taskQueue = new LinkedBlockingQueue<Runnable>();
searchSettings = new SearchSettings(new ArrayList<BinaryMapIndexReader>());
searchSettings = searchSettings.setLang(locale, transliterate);
phrase = SearchPhrase.emptyPhrase();
phrase = SearchPhrase.emptyPhrase(searchSettings);
currentSearchResult = new SearchResultCollection(phrase);
singleThreadedExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, taskQueue);
}

View file

@ -48,8 +48,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import gnu.trove.list.array.TIntArrayList;
public class SearchCoreFactory {
@ -678,7 +676,7 @@ public class SearchCoreFactory {
@Override
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent();
NameStringMatcher nm = phrase.getFullUnknownNameMatcher();
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
initPoiTypes();
List<AbstractPoiType> poiTypes = topVisibleFilters;
if (!showTopFiltersOnly) {
@ -818,18 +816,18 @@ public class SearchCoreFactory {
throw new UnsupportedOperationException();
}
} else if (searchAmenityTypesAPI != null) {
NameStringMatcher nm = phrase.getFullUnknownNameMatcher();
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
searchAmenityTypesAPI.initPoiTypes();
List<AbstractPoiType> presentPoiTypes = searchAmenityTypesAPI.getPoiTypeResults(nm, false);
// TODO get first ?
AbstractPoiType poiType = phrase.getUnknownSearchWordPoiType();
if (poiType != null) {
poiTypeFilter = getPoiTypeFilter(poiType);
nameFilter = phrase.getPoiNameFilter(poiType);
if (nameFilter != null) {
phrase.setUnknownSearchWordPoiType(poiType);
}
}
// TODO get first ? !!!
// AbstractPoiType poiType = phrase.getUnknownSearchWordPoiType();
// if (poiType != null) {
// poiTypeFilter = getPoiTypeFilter(poiType);
// nameFilter = phrase.getPoiNameFilter(poiType);
// if (nameFilter != null) {
// phrase.setUnknownSearchWordPoiType(poiType);
// }
// }
}
if (poiTypeFilter != null) {
QuadRect bbox = phrase.getRadiusBBoxToSearch(BBOX_RADIUS);
@ -853,7 +851,7 @@ public class SearchCoreFactory {
private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchResultMatcher resultMatcher,
final String nameFilter, final BinaryMapIndexReader selected,
final Set<String> searchedPois) {
// TODO
// TODO !!!
// String unknownSearchPhrase = phrase.getUnknownSearchPhrase().trim();
// final NameStringMatcher phraseMatcher;
// if (!Algorithms.isEmpty(unknownSearchPhrase)) {
@ -861,13 +859,14 @@ public class SearchCoreFactory {
// } else {
// phraseMatcher = null;
// }
final NameStringMatcher ns;
final boolean hasCustomName = !Algorithms.isEmpty(nameFilter);
if (hasCustomName) {
ns = phrase.getNameStringMatcher(nameFilter, phrase.isLastUnknownSearchWordComplete());
} else {
ns = phrase.getFirstUnknownNameStringMatcher();
}
// final NameStringMatcher ns;
// final boolean hasCustomName = !Algorithms.isEmpty(nameFilter);
// if (hasCustomName) {
// ns = phrase.getNameStringMatcher(nameFilter, phrase.isLastUnknownSearchWordComplete());
// } else {
// ns = phrase.getFirstUnknownNameStringMatcher();
// }
NameStringMatcher ns = phrase.getFirstUnknownNameStringMatcher();
return new ResultMatcher<Amenity>() {
@Override
@ -914,16 +913,17 @@ public class SearchCoreFactory {
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
res.priorityDistance = 1;
if (phraseMatcher != null) {
boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName);
AbstractPoiType unknownSearchWordPoiType = phrase.getUnknownSearchWordPoiType();
if (unknownPhraseMatches && unknownSearchWordPoiType != null) {
unknownPhraseMatches = !phraseMatcher.matches(unknownSearchWordPoiType.getTranslation())
&& !phraseMatcher.matches(unknownSearchWordPoiType.getEnTranslation())
&& !phraseMatcher.matches(unknownSearchWordPoiType.getSynonyms());
}
res.unknownPhraseMatches = unknownPhraseMatches;
}
// TODO !!!
// if (phraseMatcher != null) {
// boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName);
// AbstractPoiType unknownSearchWordPoiType = phrase.getUnknownSearchWordPoiType();
// if (unknownPhraseMatches && unknownSearchWordPoiType != null) {
// unknownPhraseMatches = !phraseMatcher.matches(unknownSearchWordPoiType.getTranslation())
// && !phraseMatcher.matches(unknownSearchWordPoiType.getEnTranslation())
// && !phraseMatcher.matches(unknownSearchWordPoiType.getSynonyms());
// }
// res.unknownPhraseMatches = unknownPhraseMatches;
// }
res.objectType = ObjectType.POI;
resultMatcher.publish(res);
return false;

View file

@ -293,15 +293,6 @@ public class SearchPhrase {
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() {
return otherUnknownWords.size() > 0;
}
@ -534,7 +525,7 @@ public class SearchPhrase {
public NameStringMatcher getUnknownNameStringMatcher(int i) {
while (unknownWordsMatcher.size() <= i) {
int ind = unknownWordsMatcher.size() - 1;
int ind = unknownWordsMatcher.size();
boolean completeMatch = ind < otherUnknownWords.size() - 1 || isLastUnknownSearchWordComplete();
unknownWordsMatcher.add(getNameStringMatcher(otherUnknownWords.get(ind), completeMatch));
}

View file

@ -55,14 +55,15 @@ public class SearchResult {
res = ObjectType.getTypeWeight(objectType);
}
if (parentSearchResult != null) {
// TODO
// 10 > maximum type
// double x = parentSearchResult.getUnknownPhraseMatchWeight();
// if (x == 0) {
// return 0;
// }
// 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;
}