Skip to content

Commit

Permalink
fixed TextSearchPredicate's syllable-matching
Browse files Browse the repository at this point in the history
  • Loading branch information
BlvckBytes committed Nov 9, 2024
1 parent 5ef6e7f commit 92937b7
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public TextSearchPredicate(QuotedStringToken token) {

var matcher = new SyllablesMatcher();

matcher.setTarget(tokenSyllables);
matcher.setQuery(tokenSyllables);

// ================================================================================
// Display Name
Expand All @@ -35,10 +35,10 @@ public TextSearchPredicate(QuotedStringToken token) {
if (state.meta.hasDisplayName()) {
var displayNameSyllables = Syllables.forString(null, state.meta.getDisplayName(), Syllables.DELIMITER_FREE_TEXT);

matcher.setQuery(displayNameSyllables);
matcher.setTarget(displayNameSyllables);
matcher.match();

if (matcher.hasUnmatchedTargetSyllables())
if (!matcher.hasUnmatchedQuerySyllables())
return null;
}

Expand All @@ -50,10 +50,10 @@ public TextSearchPredicate(QuotedStringToken token) {
for (var loreLine : Objects.requireNonNull(state.meta.getLore())) {
var loreLineSyllables = Syllables.forString(null, loreLine, Syllables.DELIMITER_FREE_TEXT);

matcher.setQuery(loreLineSyllables);
matcher.setTarget(loreLineSyllables);
matcher.match();

if (matcher.hasUnmatchedTargetSyllables())
if (!matcher.hasUnmatchedQuerySyllables())
return null;
}
}
Expand All @@ -67,10 +67,10 @@ public TextSearchPredicate(QuotedStringToken token) {
if (bookMeta.hasAuthor()) {
var authorSyllables = Syllables.forString(null, Objects.requireNonNull(bookMeta.getAuthor()), Syllables.DELIMITER_FREE_TEXT);

matcher.setQuery(authorSyllables);
matcher.setTarget(authorSyllables);
matcher.match();

if (matcher.hasUnmatchedTargetSyllables())
if (!matcher.hasUnmatchedQuerySyllables())
return null;
}

Expand All @@ -81,10 +81,10 @@ public TextSearchPredicate(QuotedStringToken token) {
if (bookMeta.hasTitle()) {
var titleSyllables = Syllables.forString(null, Objects.requireNonNull(bookMeta.getTitle()), Syllables.DELIMITER_FREE_TEXT);

matcher.setQuery(titleSyllables);
matcher.setTarget(titleSyllables);
matcher.match();

if (matcher.hasUnmatchedTargetSyllables())
if (!matcher.hasUnmatchedQuerySyllables())
return null;
}

Expand All @@ -96,10 +96,10 @@ public TextSearchPredicate(QuotedStringToken token) {
for (var page : bookMeta.getPages()) {
var pageSyllables = Syllables.forString(null, page, Syllables.DELIMITER_FREE_TEXT);

matcher.setQuery(pageSyllables);
matcher.setTarget(pageSyllables);
matcher.match();

if (matcher.hasUnmatchedTargetSyllables())
if (!matcher.hasUnmatchedQuerySyllables())
return null;
}
}
Expand All @@ -118,10 +118,10 @@ public TextSearchPredicate(QuotedStringToken token) {
if (ownerName != null) {
var ownerNameSyllables = Syllables.forString(null, ownerName, Syllables.DELIMITER_FREE_TEXT);

matcher.setQuery(ownerNameSyllables);
matcher.setTarget(ownerNameSyllables);
matcher.match();

if (matcher.hasUnmatchedTargetSyllables())
if (!matcher.hasUnmatchedQuerySyllables())
return null;
}
}
Expand Down

0 comments on commit 92937b7

Please sign in to comment.