Skip to content

Commit

Permalink
return null when score is above 90000000
Browse files Browse the repository at this point in the history
  • Loading branch information
austin007008 committed Jul 11, 2024
1 parent d096c41 commit 10bbe6a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ private void checkForHitPhrase(WordsAndScores[] terms) {
continue;
}
// iterate across the WordsAndScores until the end of the hit phrase reaches the last offset
for (int j = 0; j < terms.length - individualHitTerms.length + 1; j++) {
int iterations = terms.length - individualHitTerms.length + 1;
for (int j = 0; j < iterations; j++) {
// if we find the hit phrase...
if (isPhraseFound(individualHitTerms, terms, j)) {
// set which position in the phrase each offset is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public boolean addTerm(String word, List<String> hitTermsList) {
scores.add(-1); // add the default score to its array
if (arrSize > 1) { // if this is at least the second word we are adding...
if ((hitTermsList != null) && hitTermsList.contains(word)) { // if this word is a hit term...
if (hitTermIndex == -1) { // if we don't have a hit term at this offset yet..
if (hitTermIndex == -1) { // if we don't have a hit term at this offset yet...
hitTermIndex = arrSize - 1; // set this index as the one with a hit term
hasHitTerm = true;
} else {
Expand Down Expand Up @@ -172,6 +172,9 @@ public String getWordToOutput() {
return "REPORTMETODATAWAVE";
} else {
if (oneBestExcerpt) {
if (scores.get(smallestScoreIndex) > 90000000) {
return null;
}
if (STOP_WORD_LIST.contains(words.get(smallestScoreIndex))) { // if the selected term is in the stop list...
return null;
}
Expand All @@ -182,6 +185,9 @@ public String getWordToOutput() {
}
}
if (overrideIndex >= 0 && overrideIndex < arrSize) {
if (scores.get(overrideIndex) > 90000000) {
return null;
}
if (STOP_WORD_LIST.contains(words.get(overrideIndex))) { // if the hit term is on the stop list for some reason...
return null;
}
Expand Down Expand Up @@ -210,6 +216,9 @@ public String getWordToOutput() {
}
}
if (hasHitTerm) { // if we have a hit term...
if (scores.get(hitTermIndex) > 90000000) {
return null;
}
if (STOP_WORD_LIST.contains(words.get(hitTermIndex))) { // if the hit term is on the stop list for some reason...
return null;
}
Expand All @@ -220,6 +229,9 @@ public String getWordToOutput() {
}
}
if (useScores) { // if we have added at least one score, and it is a valid score...
if (scores.get(smallestScoreIndex) > 90000000) {
return null;
}
if (STOP_WORD_LIST.contains(words.get(smallestScoreIndex))) { // if the selected term is in the stop list...
return null;
}
Expand Down

0 comments on commit 10bbe6a

Please sign in to comment.