use of com.yahoo.prelude.query.Substring in project vespa by vespa-engine.
the class YqlParserTestCase method testWordAlternativesWithOrigin.
@Test
public void testWordAlternativesWithOrigin() {
QueryTree x = parse("select * from sources * where foo contains" + " ([{\"origin\": {\"original\": \" trees \", \"offset\": 1, \"length\": 5}}]" + "alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
Item root = x.getRoot();
assertSame(WordAlternativesItem.class, root.getClass());
WordAlternativesItem alternatives = (WordAlternativesItem) root;
checkWordAlternativesContent(alternatives);
Substring origin = alternatives.getOrigin();
assertEquals(1, origin.start);
assertEquals(6, origin.end);
assertEquals("trees", origin.getValue());
assertEquals(" trees ", origin.getSuperstring());
}
use of com.yahoo.prelude.query.Substring 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