use of com.yahoo.prelude.query.PhraseItem in project vespa by vespa-engine.
the class WashPhrasesTestCase method testSimplePositive.
@Test
public void testSimplePositive() {
PhraseItem root = new PhraseItem();
root.addItem(new WordItem("abc"));
assertEquals("abc", transformQuery(root));
}
use of com.yahoo.prelude.query.PhraseItem in project vespa by vespa-engine.
the class PhraseItemTestCase method testAddItem.
@Test
public void testAddItem() {
PhraseItem p = new PhraseItem();
PhraseSegmentItem pp = new PhraseSegmentItem("", false, false);
PhraseItem ppp = new PhraseItem();
pp.addItem(new WordItem("b"));
pp.addItem(new WordItem("c"));
ppp.addItem(new WordItem("e"));
ppp.addItem(new WordItem("f"));
p.addItem(new WordItem("a"));
p.addItem(pp);
p.addItem(new WordItem("d"));
p.addItem(ppp);
assertEquals("\"a 'b c' d e f\"", p.toString());
}
use of com.yahoo.prelude.query.PhraseItem in project vespa by vespa-engine.
the class PhraseItemTestCase method testSetItem.
@Test
public void testSetItem() {
PhraseItem backup = new PhraseItem();
PhraseSegmentItem segment = new PhraseSegmentItem("", false, false);
PhraseItem innerPhrase = new PhraseItem();
WordItem testWord = new WordItem("z");
PhraseItem p;
segment.addItem(new WordItem("p"));
segment.addItem(new WordItem("q"));
innerPhrase.addItem(new WordItem("x"));
innerPhrase.addItem(new WordItem("y"));
backup.addItem(new WordItem("a"));
backup.addItem(new WordItem("b"));
backup.addItem(new WordItem("c"));
p = (PhraseItem) backup.clone();
p.setItem(0, segment);
assertEquals("\"'p q' b c\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(1, segment);
assertEquals("\"a 'p q' c\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(2, segment);
assertEquals("\"a b 'p q'\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(0, innerPhrase);
assertEquals("\"x y b c\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(1, innerPhrase);
assertEquals("\"a x y c\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(2, innerPhrase);
assertEquals("\"a b x y\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(0, testWord);
assertEquals("\"z b c\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(1, testWord);
assertEquals("\"a z c\"", p.toString());
p = (PhraseItem) backup.clone();
p.setItem(2, testWord);
assertEquals("\"a b z\"", p.toString());
}
use of com.yahoo.prelude.query.PhraseItem in project vespa by vespa-engine.
the class PhrasingSearcherTestCase method testTotalPhrasing.
@Test
public void testTotalPhrasing() {
Searcher searcher = new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
Query query = new Query();
AndItem andItem = new AndItem();
andItem.addItem(new WordItem("tudor", "someindex"));
andItem.addItem(new WordItem("vidor", "someindex"));
query.getModel().getQueryTree().setRoot(andItem);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
Item item = ((CompositeItem) query.getModel().getQueryTree().getRoot()).getItem(0);
assertTrue(item instanceof PhraseItem);
PhraseItem phrase = (PhraseItem) item;
assertEquals(2, phrase.getItemCount());
assertEquals("tudor", phrase.getWordItem(0).getWord());
assertEquals("vidor", phrase.getWordItem(1).getWord());
assertEquals("someindex", phrase.getIndexName());
}
use of com.yahoo.prelude.query.PhraseItem in project vespa by vespa-engine.
the class QueryLanguageTestCase method testPhrase.
@Test
public void testPhrase() {
PhraseItem p = new PhraseItem();
p.addItem(new WordItem("part"));
p.addItem(new WordItem("of"));
p.addItem(new WordItem("phrase"));
assertEquals("\"part of phrase\"", p.toString());
}
Aggregations