This commit is contained in:
Victor Shcherb 2021-04-19 20:10:19 +02:00
parent a657d71e06
commit 08baaf7004
2 changed files with 6 additions and 4 deletions

View file

@ -55,7 +55,9 @@ public class SearchResult {
public double getSumPhraseMatchWeight() {
// if result is a complete match in the search we prioritize it higher
boolean match = requiredSearchPhrase.countWords(localeName) <= getSelfWordCount();
int localWordsMatched = alternateName != null ?
requiredSearchPhrase.countWords(alternateName) : requiredSearchPhrase.countWords(localeName) ;
boolean match = localWordsMatched <= getSelfWordCount();
double res = ObjectType.getTypeWeight(match ? objectType : null);
if (parentSearchResult != null) {
res = res + parentSearchResult.getSumPhraseMatchWeight() / MAX_TYPE_WEIGHT;

View file

@ -80,9 +80,9 @@ public class SearchUICoreTest {
if (files != null) {
for (File file : files) {
String fileName = file.getName();
if(fileName.endsWith(".json")) {
if (fileName.endsWith(".json")) {
String name = fileName.substring(0, fileName.length() - ".json".length());
arrayList.add(new Object[] {name, file});
arrayList.add(new Object[] { name, file });
}
}
}
@ -191,10 +191,10 @@ public class SearchUICoreTest {
if (!Algorithms.stringsEqual(expected, present)) {
System.out.println(String.format("Phrase: %s", phrase));
System.out.println(String.format("Mismatch for '%s' != '%s'. Result: ", expected, present));
}
for (SearchResult r : searchResults) {
System.out.println(String.format("\t\"%s\",", formatResult(false, r, phrase)));
}
}
Assert.assertEquals(expected, present);
}
}