Merge branch 'try_fix_9329'
This commit is contained in:
commit
3d7c4b3fc8
2 changed files with 14 additions and 8 deletions
|
@ -55,11 +55,11 @@ public enum ObjectType {
|
||||||
return 4;
|
return 4;
|
||||||
case STREET:
|
case STREET:
|
||||||
return 3;
|
return 3;
|
||||||
case POI:
|
|
||||||
return 2;
|
|
||||||
case CITY:
|
case CITY:
|
||||||
case VILLAGE:
|
case VILLAGE:
|
||||||
case POSTCODE:
|
case POSTCODE:
|
||||||
|
return 2;
|
||||||
|
case POI:
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -49,13 +49,14 @@ public class SearchResult {
|
||||||
|
|
||||||
// maximum corresponds to the top entry
|
// maximum corresponds to the top entry
|
||||||
public double getUnknownPhraseMatchWeight() {
|
public double getUnknownPhraseMatchWeight() {
|
||||||
// if result is a complete match in the search we prioritize it highers
|
// if result is a complete match in the search we prioritize it higher
|
||||||
return getSumPhraseMatchWeight() / Math.pow(MAX_TYPE_WEIGHT, getDepth() - 1);
|
return getSumPhraseMatchWeight() / Math.pow(MAX_TYPE_WEIGHT, getDepth() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getSumPhraseMatchWeight() {
|
public double getSumPhraseMatchWeight() {
|
||||||
// if result is a complete match in the search we prioritize it highers
|
// if result is a complete match in the search we prioritize it higher
|
||||||
double res = ObjectType.getTypeWeight(objectType);
|
boolean match = requiredSearchPhrase.countWords(localeName) <= getSelfWordCount();
|
||||||
|
double res = ObjectType.getTypeWeight(match ? objectType : null);
|
||||||
if (parentSearchResult != null) {
|
if (parentSearchResult != null) {
|
||||||
res = res + parentSearchResult.getSumPhraseMatchWeight() / MAX_TYPE_WEIGHT;
|
res = res + parentSearchResult.getSumPhraseMatchWeight() / MAX_TYPE_WEIGHT;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,14 @@ public class SearchResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFoundWordCount() {
|
public int getFoundWordCount() {
|
||||||
|
int inc = getSelfWordCount();
|
||||||
|
if (parentSearchResult != null) {
|
||||||
|
inc += parentSearchResult.getFoundWordCount();
|
||||||
|
}
|
||||||
|
return inc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSelfWordCount() {
|
||||||
int inc = 0;
|
int inc = 0;
|
||||||
if (firstUnknownWordMatches) {
|
if (firstUnknownWordMatches) {
|
||||||
inc = 1;
|
inc = 1;
|
||||||
|
@ -77,9 +86,6 @@ public class SearchResult {
|
||||||
if (otherWordsMatch != null) {
|
if (otherWordsMatch != null) {
|
||||||
inc += otherWordsMatch.size();
|
inc += otherWordsMatch.size();
|
||||||
}
|
}
|
||||||
if (parentSearchResult != null) {
|
|
||||||
inc += parentSearchResult.getFoundWordCount();
|
|
||||||
}
|
|
||||||
return inc;
|
return inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue