use of com.yahoo.prelude.query.WordAlternativesItem in project vespa by vespa-engine.
the class NormalizingSearcherTestCase method testLiteralBoost.
@Test
public void testLiteralBoost() {
Query query = new Query("/search?query=nop&search=cluster1&restrict=type1");
List<WordAlternativesItem.Alternative> terms = new ArrayList<>();
Substring origin = new Substring(0, 5, "h\u00F4tels");
terms.add(new WordAlternativesItem.Alternative("h\u00F4tels", 1.0d));
terms.add(new WordAlternativesItem.Alternative("h\u00F4tel", 0.7d));
query.getModel().getQueryTree().setRoot(new WordAlternativesItem("default", true, origin, terms));
createExecution().search(query);
WordAlternativesItem w = (WordAlternativesItem) query.getModel().getQueryTree().getRoot();
assertEquals(4, w.getAlternatives().size());
boolean foundHotel = false;
for (WordAlternativesItem.Alternative a : w.getAlternatives()) {
if ("hotel".equals(a.word)) {
foundHotel = true;
assertEquals(.7d * .7d, a.exactness, 1e-15);
}
}
assertTrue("Did not find the expected normalized form \"hotel\".", foundHotel);
}
Aggregations