From 6284f97a5042a08b884de706218776f4b29689bc Mon Sep 17 00:00:00 2001 From: Gleb Sizov Date: Thu, 22 Aug 2024 14:04:59 +0200 Subject: [PATCH 1/6] fixed the resolver, added and refactored relevant tests --- .../significance/SignificanceSearcher.java | 8 +- .../test/SignificanceSearcherTest.java | 117 ++++++++++++------ 2 files changed, 81 insertions(+), 44 deletions(-) diff --git a/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java b/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java index d0576295b365..6aa15d284fca 100644 --- a/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java @@ -132,14 +132,8 @@ private SignificanceModel getSignificanceModelFromQueryLanguage(Query query) thr return model.get(); } - if (implicitLanguage == Language.UNKNOWN) { - return handleFallBackToUnknownLanguage(); - } var model = significanceModelRegistry.getModel(implicitLanguage); - if (model.isEmpty()) { - throw new IllegalArgumentException("No significance model available for implicit language " + implicitLanguage); - } - return model.get(); + return model.orElseGet(this::handleFallBackToUnknownLanguage); } private SignificanceModel handleFallBackToUnknownLanguage() throws IllegalArgumentException { diff --git a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java index e71a31fea2c1..3f09713598dc 100644 --- a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java @@ -2,13 +2,11 @@ package com.yahoo.search.significance.test; import com.yahoo.component.chain.Chain; -import com.yahoo.config.subscription.ConfigGetter; import com.yahoo.language.Language; import com.yahoo.language.Linguistics; import com.yahoo.language.detect.Detection; import com.yahoo.language.detect.Detector; import com.yahoo.language.detect.Hint; -import com.yahoo.language.opennlp.OpenNlpLinguistics; import com.yahoo.language.process.*; import com.yahoo.language.significance.SignificanceModel; import com.yahoo.language.significance.SignificanceModelRegistry; @@ -24,13 +22,11 @@ import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.significance.SignificanceSearcher; -import com.yahoo.vespa.config.search.RankProfilesConfig; import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.nio.file.Path; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -305,50 +301,97 @@ public void failsOnConflictingSignificanceConfiguration() { errorMessage.getDetailedMessage()); } - @Test - public void testSignificanceSearcherWithExplictitAndImplictSetLanguages() { - Query q = new Query(); - q.getModel().setLanguage(Language.UNKNOWN); - q.getRanking().setProfile("significance-ranking"); - AndItem root = new AndItem(); - WordItem tmp; - tmp = new WordItem("hello", true); - root.addItem(tmp); + // Naming convention for tests that follow: + // Explicit language - language set for a query + // Implicit language - automatically detected language + // Missing language - language without a model + // Unknown language - Language.UNKNOWN + // Missing word - word not in the model for specified language or fallback models + // Existing word - word in the model for a specified language or fallback models - q.getModel().getQueryTree().setRoot(root); + private Result searchWordWithLanguage(String word, Optional explicitLanguage, Optional implicitLanguage) { + var query = new Query(); + explicitLanguage.ifPresent(language -> query.getModel().setLanguage(language)); + query.getRanking().setProfile("significance-ranking"); + var queryRoot = new AndItem(); + var queryWord = new WordItem(word, true); + queryRoot.addItem(queryWord); + query.getModel().getQueryTree().setRoot(queryRoot); - SignificanceModel model = significanceModelRegistry.getModel(Language.ENGLISH).get(); - var helloDocumentFrequency = makeDocumentFrequency(model.documentFrequency("hello")); - Result r = createExecution(searcher).search(q); + var context = Execution.Context.createContextStub(); + implicitLanguage.ifPresent(language -> context.setLinguistics(new MockLinguistics(language))); + var execution = new Execution(new Chain<>(searcher), context); + return execution.search(query); + } - root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot(); - WordItem w0 = (WordItem) root.getItem(0); - assertEquals(helloDocumentFrequency, w0.getDocumentFrequency()); + private Optional getDocumentFrequencyWithEnglish(String word) { + SignificanceModel model = significanceModelRegistry.getModel(Language.ENGLISH).get(); + return makeDocumentFrequency(model.documentFrequency(word)); + } - Query q2 = new Query(); - q2.getModel().setLanguage(Language.FRENCH); - q2.getRanking().setProfile("significance-ranking"); - AndItem root2 = new AndItem(); - WordItem tmp2; - tmp2 = new WordItem("hello", true); - root2.addItem(tmp2); + @Test + public void testSignificanceSearcherWithMissingExplicitLanguageOnExistingWord() { + var existingWord = "hello"; + var explicitLanguage = Language.ITALIAN; + var result = searchWordWithLanguage(existingWord, Optional.of(explicitLanguage), Optional.empty()); - q2.getModel().getQueryTree().setRoot(root2); - Result r2 = createExecution(searcher).search(q2); + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + var resultWord = (WordItem) resultRoot.getItem(0); + assertEquals(Optional.empty(), resultWord.getDocumentFrequency()); - assertEquals(1, r2.hits().getErrorHit().errors().size()); + var error = result.hits().getError().getDetailedMessage(); + assertEquals("No significance model available for set language ITALIAN", error); + } + @Test + public void testSignificanceSearcherWithUnknownExplicitLanguageOnExistingWord() { + var existingWord = "hello"; + var explicitLanguage = Language.UNKNOWN; + var result = searchWordWithLanguage(existingWord, Optional.of(explicitLanguage), Optional.empty()); + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + var resultWord = (WordItem) resultRoot.getItem(0); + var existingDocumentFrequency = getDocumentFrequencyWithEnglish(existingWord); + assertEquals(existingDocumentFrequency, resultWord.getDocumentFrequency()); + } - Query q3 = new Query(); - q3.getRanking().setProfile("significance-ranking"); - WordItem root3 = new WordItem("Я с детства хотел завести собаку, но родители мне не разрешали.", true); + @Test + public void testSignificanceSearcherWithMissingExplicitLanguageOnMissingWord() { + var missingWord = "ciao"; + var explicitLanguage = Language.ITALIAN; + var result = searchWordWithLanguage(missingWord, Optional.of(explicitLanguage), Optional.empty()); - q3.getModel().getQueryTree().setRoot(root3); - Execution execution = createExecution(searcher, Language.RUSSIAN); - Result r3 = execution.search(q3); + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + var resultWord = (WordItem) resultRoot.getItem(0); + assertEquals(Optional.empty(), resultWord.getDocumentFrequency()); - assertEquals(1, r3.hits().getErrorHit().errors().size()); + var error = result.hits().getError().getDetailedMessage(); + assertEquals("No significance model available for set language ITALIAN", error); + } + @Test + public void testSignificanceSearcherWithMissingImplicitLanguageOnExistingWord() { + var existingWord = "hello"; + var implicitLanguage = Language.ITALIAN; + var result = searchWordWithLanguage(existingWord, Optional.empty(), Optional.of(implicitLanguage)); + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + var resultWord = (WordItem) resultRoot.getItem(0); + var existingDocumentFrequency = getDocumentFrequencyWithEnglish(existingWord); + assertEquals(existingDocumentFrequency, resultWord.getDocumentFrequency()); + } + @Test + public void testSignificanceSearcherWithMissingImplicitLanguageOnMissingWord() { + var implicitLanguage = Language.ITALIAN; + var missingWord = "ciao"; + var result = searchWordWithLanguage(missingWord, Optional.empty(), Optional.of(implicitLanguage)); + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + var resultWord = (WordItem) resultRoot.getItem(0); + + var existingWord = "hello"; + var documentFrequency = getDocumentFrequencyWithEnglish(existingWord); + var count = documentFrequency.get().count(); + var defaultDocumentFrequency = Optional.of(new DocumentFrequency(1, count)); + + assertEquals(defaultDocumentFrequency, resultWord.getDocumentFrequency()); } } From 3287fcb060e7d0ec90c7ae6d6b2a22cedd59344a Mon Sep 17 00:00:00 2001 From: Gleb Sizov Date: Thu, 22 Aug 2024 14:13:49 +0200 Subject: [PATCH 2/6] added comment --- .../yahoo/search/significance/SignificanceSearcher.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java b/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java index 6aa15d284fca..adea0013e3de 100644 --- a/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java @@ -114,6 +114,15 @@ private Result calculateAndSetSignificance(Query query, Execution execution) { } private SignificanceModel getSignificanceModelFromQueryLanguage(Query query) throws IllegalArgumentException { + /* + Implements the following model resolving logic: + - When language is explicitly tagged on query + - Use language if available from the model registry, fail otherwise. + - If “un” try both “un” and “en”. + - When language is implicitly detected + - Use language if available from the model registry. Fallback to “un” then “en”, fail if none are available. + */ + Language explicitLanguage = query.getModel().getLanguage(); Language implicitLanguage = query.getModel().getParsingLanguage(); From dd686fa3061a6cbe477fd8c7850ccc25f7a37f61 Mon Sep 17 00:00:00 2001 From: Gleb Sizov Date: Thu, 22 Aug 2024 14:54:53 +0200 Subject: [PATCH 3/6] Minor doc update --- .../search/significance/test/SignificanceSearcherTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java index 3f09713598dc..00ffc8c4d17e 100644 --- a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java @@ -301,8 +301,9 @@ public void failsOnConflictingSignificanceConfiguration() { errorMessage.getDetailedMessage()); } - // Naming convention for tests that follow: - // Explicit language - language set for a query + // Tests that follow verify model resolving logic in different scenarios. + // Test naming convention is as follows: + // Explicit language - language set in a query // Implicit language - automatically detected language // Missing language - language without a model // Unknown language - Language.UNKNOWN From 008a82b8f62bce802f79950d0776f0a02a5abaf5 Mon Sep 17 00:00:00 2001 From: Gleb Sizov Date: Thu, 22 Aug 2024 15:29:34 +0200 Subject: [PATCH 4/6] fix for handling upper case in queries --- container-search/pom.xml | 5 +++++ .../significance/SignificanceSearcher.java | 2 +- .../test/SignificanceSearcherTest.java | 20 +++++++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/container-search/pom.xml b/container-search/pom.xml index 5e7c60d49c33..9e990d2b41ff 100644 --- a/container-search/pom.xml +++ b/container-search/pom.xml @@ -183,6 +183,11 @@ junit-jupiter-engine test + + org.junit.jupiter + junit-jupiter-params + test + diff --git a/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java b/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java index adea0013e3de..5976502ed1c7 100644 --- a/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/significance/SignificanceSearcher.java @@ -161,7 +161,7 @@ private void setIDF(Item root, SignificanceModel significanceModel) { if (root instanceof WordItem wi) { var word = wi.getWord(); - var documentFrequency = significanceModel.documentFrequency(word); + var documentFrequency = significanceModel.documentFrequency(word.toLowerCase()); long N = documentFrequency.corpusSize(); long nq_i = documentFrequency.frequency(); log.log(Level.FINE, () -> "Setting document frequency for " + word + " to {frequency: " + nq_i + ", count: " + N + "}"); diff --git a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java index 00ffc8c4d17e..f8ee7f1703cb 100644 --- a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java @@ -23,6 +23,8 @@ import com.yahoo.search.searchchain.Execution; import com.yahoo.search.significance.SignificanceSearcher; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import java.nio.ByteBuffer; import java.nio.file.Path; @@ -214,7 +216,7 @@ void testSignificanceValueOnSimpleANDQuery() { q.getModel().getQueryTree().setRoot(root); SignificanceModel model = significanceModelRegistry.getModel(Language.ENGLISH).get(); - var helloDocumentFrequency = makeDocumentFrequency(model.documentFrequency("Hello")); + var helloDocumentFrequency = makeDocumentFrequency(model.documentFrequency("hello")); var worldDocumentFrequency = makeDocumentFrequency(model.documentFrequency("world")); Result r = createExecution(searcher).search(q); @@ -395,4 +397,18 @@ public void testSignificanceSearcherWithMissingImplicitLanguageOnMissingWord() { assertEquals(defaultDocumentFrequency, resultWord.getDocumentFrequency()); } -} + + // Tests for upper case words in a query + @ParameterizedTest + @ValueSource(strings = {"Hello", "HeLlo", "HELLO"}) + public void testSignificanceSearcherWithUpperCaseWord(String wordWithUpperCase) { + var result = searchWordWithLanguage(wordWithUpperCase, Optional.of(Language.ENGLISH), Optional.empty()); + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + var resultWord = (WordItem) resultRoot.getItem(0); + + var lowerCaseWord = "hello"; + var documentFrequency = getDocumentFrequencyWithEnglish(lowerCaseWord); + + assertEquals(documentFrequency, resultWord.getDocumentFrequency()); + } +} \ No newline at end of file From 199173365c87fce21ecdae0e153a2fcc2813d914 Mon Sep 17 00:00:00 2001 From: Gleb Sizov Date: Fri, 23 Aug 2024 08:45:50 +0200 Subject: [PATCH 5/6] Extracted methods to improve tests readability --- .../test/SignificanceSearcherTest.java | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java index f8ee7f1703cb..36ac40208f3f 100644 --- a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java @@ -254,9 +254,9 @@ void testSignificanceValueOnRecursiveQuery() { q.getModel().getQueryTree().setRoot(root); - SignificanceModel model = significanceModelRegistry.getModel(Language.ENGLISH).get(); - var helloDocumentFrequency = makeDocumentFrequency(model.documentFrequency("hello")); - var testDocumentFrequency = makeDocumentFrequency(model.documentFrequency("test")); + var helloDocumentFrequency = getDocumentFrequencyWithEnglish("hello"); + var testDocumentFrequency = getDocumentFrequencyWithEnglish("test"); + Result r = createExecution(searcher).search(q); root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot(); @@ -294,25 +294,25 @@ public void failsOnConflictingSignificanceConfiguration() { var result = createExecution(searcher).search(query); assertEquals(1, result.hits().getErrorHit().errors().size()); - var errorMessage = result.hits().getError(); + var errorMessage = getErrorMessage(result); assertEquals("Inconsistent 'significance' configuration for the rank profile 'significance-ranking' in the schemas [music, album]. " + "Use 'restrict' to limit the query to a subset of schemas " + "(https://docs.vespa.ai/en/schemas.html#multiple-schemas). " + "Specify same 'significance' configuration for all selected schemas " + "(https://docs.vespa.ai/en/reference/schema-reference.html#significance).", - errorMessage.getDetailedMessage()); + errorMessage); } // Tests that follow verify model resolving logic in different scenarios. // Test naming convention is as follows: // Explicit language - language set in a query - // Implicit language - automatically detected language + // Implicit language - language detected automatically // Missing language - language without a model // Unknown language - Language.UNKNOWN - // Missing word - word not in the model for specified language or fallback models - // Existing word - word in the model for a specified language or fallback models + // Missing word - word not in a model for the specified language or fallback models + // Existing word - word in a model for the specified language or fallback models - private Result searchWordWithLanguage(String word, Optional explicitLanguage, Optional implicitLanguage) { + private Result searchWord(String word, Optional explicitLanguage, Optional implicitLanguage) { var query = new Query(); explicitLanguage.ifPresent(language -> query.getModel().setLanguage(language)); query.getRanking().setProfile("significance-ranking"); @@ -332,27 +332,34 @@ private Optional getDocumentFrequencyWithEnglish(String word) return makeDocumentFrequency(model.documentFrequency(word)); } + private static WordItem getFistWord(Result result) { + var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); + return (WordItem) resultRoot.getItem(0); + } + + private static String getErrorMessage(Result result) { + return result.hits().getError().getDetailedMessage(); + } + @Test public void testSignificanceSearcherWithMissingExplicitLanguageOnExistingWord() { var existingWord = "hello"; var explicitLanguage = Language.ITALIAN; - var result = searchWordWithLanguage(existingWord, Optional.of(explicitLanguage), Optional.empty()); + var result = searchWord(existingWord, Optional.of(explicitLanguage), Optional.empty()); - var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); - var resultWord = (WordItem) resultRoot.getItem(0); + var resultWord = getFistWord(result); assertEquals(Optional.empty(), resultWord.getDocumentFrequency()); - var error = result.hits().getError().getDetailedMessage(); - assertEquals("No significance model available for set language ITALIAN", error); + var errorMessage = getErrorMessage(result); + assertEquals("No significance model available for set language ITALIAN", errorMessage); } @Test public void testSignificanceSearcherWithUnknownExplicitLanguageOnExistingWord() { var existingWord = "hello"; var explicitLanguage = Language.UNKNOWN; - var result = searchWordWithLanguage(existingWord, Optional.of(explicitLanguage), Optional.empty()); - var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); - var resultWord = (WordItem) resultRoot.getItem(0); + var result = searchWord(existingWord, Optional.of(explicitLanguage), Optional.empty()); + var resultWord = getFistWord(result); var existingDocumentFrequency = getDocumentFrequencyWithEnglish(existingWord); assertEquals(existingDocumentFrequency, resultWord.getDocumentFrequency()); } @@ -361,23 +368,21 @@ public void testSignificanceSearcherWithUnknownExplicitLanguageOnExistingWord() public void testSignificanceSearcherWithMissingExplicitLanguageOnMissingWord() { var missingWord = "ciao"; var explicitLanguage = Language.ITALIAN; - var result = searchWordWithLanguage(missingWord, Optional.of(explicitLanguage), Optional.empty()); + var result = searchWord(missingWord, Optional.of(explicitLanguage), Optional.empty()); - var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); - var resultWord = (WordItem) resultRoot.getItem(0); + var resultWord = getFistWord(result); assertEquals(Optional.empty(), resultWord.getDocumentFrequency()); - var error = result.hits().getError().getDetailedMessage(); - assertEquals("No significance model available for set language ITALIAN", error); + var errorMessage = getErrorMessage(result); + assertEquals("No significance model available for set language ITALIAN", errorMessage); } @Test public void testSignificanceSearcherWithMissingImplicitLanguageOnExistingWord() { var existingWord = "hello"; var implicitLanguage = Language.ITALIAN; - var result = searchWordWithLanguage(existingWord, Optional.empty(), Optional.of(implicitLanguage)); - var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); - var resultWord = (WordItem) resultRoot.getItem(0); + var result = searchWord(existingWord, Optional.empty(), Optional.of(implicitLanguage)); + var resultWord = getFistWord(result); var existingDocumentFrequency = getDocumentFrequencyWithEnglish(existingWord); assertEquals(existingDocumentFrequency, resultWord.getDocumentFrequency()); } @@ -386,9 +391,8 @@ public void testSignificanceSearcherWithMissingImplicitLanguageOnExistingWord() public void testSignificanceSearcherWithMissingImplicitLanguageOnMissingWord() { var implicitLanguage = Language.ITALIAN; var missingWord = "ciao"; - var result = searchWordWithLanguage(missingWord, Optional.empty(), Optional.of(implicitLanguage)); - var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); - var resultWord = (WordItem) resultRoot.getItem(0); + var result = searchWord(missingWord, Optional.empty(), Optional.of(implicitLanguage)); + var resultWord = getFistWord(result); var existingWord = "hello"; var documentFrequency = getDocumentFrequencyWithEnglish(existingWord); @@ -402,9 +406,8 @@ public void testSignificanceSearcherWithMissingImplicitLanguageOnMissingWord() { @ParameterizedTest @ValueSource(strings = {"Hello", "HeLlo", "HELLO"}) public void testSignificanceSearcherWithUpperCaseWord(String wordWithUpperCase) { - var result = searchWordWithLanguage(wordWithUpperCase, Optional.of(Language.ENGLISH), Optional.empty()); - var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); - var resultWord = (WordItem) resultRoot.getItem(0); + var result = searchWord(wordWithUpperCase, Optional.of(Language.ENGLISH), Optional.empty()); + var resultWord = getFistWord(result); var lowerCaseWord = "hello"; var documentFrequency = getDocumentFrequencyWithEnglish(lowerCaseWord); From f45ed3e541cc6c02b6885dd1e9c6fe6a94bbe379 Mon Sep 17 00:00:00 2001 From: Gleb Sizov Date: Fri, 23 Aug 2024 10:55:57 +0200 Subject: [PATCH 6/6] fixed typo --- .../test/SignificanceSearcherTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java index 36ac40208f3f..07756bbb83fc 100644 --- a/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/significance/test/SignificanceSearcherTest.java @@ -332,7 +332,7 @@ private Optional getDocumentFrequencyWithEnglish(String word) return makeDocumentFrequency(model.documentFrequency(word)); } - private static WordItem getFistWord(Result result) { + private static WordItem getFirstWord(Result result) { var resultRoot = (AndItem) result.getQuery().getModel().getQueryTree().getRoot(); return (WordItem) resultRoot.getItem(0); } @@ -347,7 +347,7 @@ public void testSignificanceSearcherWithMissingExplicitLanguageOnExistingWord() var explicitLanguage = Language.ITALIAN; var result = searchWord(existingWord, Optional.of(explicitLanguage), Optional.empty()); - var resultWord = getFistWord(result); + var resultWord = getFirstWord(result); assertEquals(Optional.empty(), resultWord.getDocumentFrequency()); var errorMessage = getErrorMessage(result); @@ -359,7 +359,7 @@ public void testSignificanceSearcherWithUnknownExplicitLanguageOnExistingWord() var existingWord = "hello"; var explicitLanguage = Language.UNKNOWN; var result = searchWord(existingWord, Optional.of(explicitLanguage), Optional.empty()); - var resultWord = getFistWord(result); + var resultWord = getFirstWord(result); var existingDocumentFrequency = getDocumentFrequencyWithEnglish(existingWord); assertEquals(existingDocumentFrequency, resultWord.getDocumentFrequency()); } @@ -370,7 +370,7 @@ public void testSignificanceSearcherWithMissingExplicitLanguageOnMissingWord() { var explicitLanguage = Language.ITALIAN; var result = searchWord(missingWord, Optional.of(explicitLanguage), Optional.empty()); - var resultWord = getFistWord(result); + var resultWord = getFirstWord(result); assertEquals(Optional.empty(), resultWord.getDocumentFrequency()); var errorMessage = getErrorMessage(result); @@ -382,7 +382,7 @@ public void testSignificanceSearcherWithMissingImplicitLanguageOnExistingWord() var existingWord = "hello"; var implicitLanguage = Language.ITALIAN; var result = searchWord(existingWord, Optional.empty(), Optional.of(implicitLanguage)); - var resultWord = getFistWord(result); + var resultWord = getFirstWord(result); var existingDocumentFrequency = getDocumentFrequencyWithEnglish(existingWord); assertEquals(existingDocumentFrequency, resultWord.getDocumentFrequency()); } @@ -392,7 +392,7 @@ public void testSignificanceSearcherWithMissingImplicitLanguageOnMissingWord() { var implicitLanguage = Language.ITALIAN; var missingWord = "ciao"; var result = searchWord(missingWord, Optional.empty(), Optional.of(implicitLanguage)); - var resultWord = getFistWord(result); + var resultWord = getFirstWord(result); var existingWord = "hello"; var documentFrequency = getDocumentFrequencyWithEnglish(existingWord); @@ -407,7 +407,7 @@ public void testSignificanceSearcherWithMissingImplicitLanguageOnMissingWord() { @ValueSource(strings = {"Hello", "HeLlo", "HELLO"}) public void testSignificanceSearcherWithUpperCaseWord(String wordWithUpperCase) { var result = searchWord(wordWithUpperCase, Optional.of(Language.ENGLISH), Optional.empty()); - var resultWord = getFistWord(result); + var resultWord = getFirstWord(result); var lowerCaseWord = "hello"; var documentFrequency = getDocumentFrequencyWithEnglish(lowerCaseWord);