use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class QueryTestCase method testUnicodeNormalization.
@Test
public void testUnicodeNormalization() {
Linguistics linguistics = new SimpleLinguistics();
Query query = newQueryFromEncoded("?query=content:%EF%BC%B3%EF%BC%AF%EF%BC%AE%EF%BC%B9", Language.ENGLISH, linguistics);
assertEquals("SONY", ((WordItem) query.getModel().getQueryTree().getRoot()).getWord());
query = newQueryFromEncoded("?query=foo&filter=+%EF%BC%B3%EF%BC%AF%EF%BC%AE%EF%BC%B9", Language.ENGLISH, linguistics);
assertEquals("RANK foo |SONY", query.getModel().getQueryTree().getRoot().toString());
query = newQueryFromEncoded("?query=foo+AND+%EF%BC%B3%EF%BC%AF%EF%BC%AE%EF%BC%B9)&type=adv", Language.ENGLISH, linguistics);
assertEquals("AND foo SONY", query.getModel().getQueryTree().getRoot().toString());
}
use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class ExpressionConverterTestCase method requireThatAllExpressionTypesCanBeTraversed.
@SuppressWarnings("unchecked")
@Test
public void requireThatAllExpressionTypesCanBeTraversed() {
assertConvertable(new ArithmeticExpression(new InputExpression("foo"), ArithmeticExpression.Operator.ADD, new InputExpression("bar")));
assertConvertable(new AttributeExpression("foo"));
assertConvertable(new Base64DecodeExpression());
assertConvertable(new Base64EncodeExpression());
assertConvertable(new CatExpression(new InputExpression("foo"), new IndexExpression("bar")));
assertConvertable(new ClearStateExpression());
assertConvertable(new EchoExpression());
assertConvertable(new ForEachExpression(new IndexExpression("foo")));
assertConvertable(new GetFieldExpression("foo"));
assertConvertable(new GetVarExpression("foo"));
assertConvertable(new GuardExpression(new IndexExpression("foo")));
assertConvertable(new HexDecodeExpression());
assertConvertable(new HexEncodeExpression());
assertConvertable(new HostNameExpression());
assertConvertable(new IfThenExpression(new InputExpression("foo"), IfThenExpression.Comparator.EQ, new InputExpression("bar"), new IndexExpression("baz"), new IndexExpression("cox")));
assertConvertable(new IndexExpression("foo"));
assertConvertable(new InputExpression("foo"));
assertConvertable(new JoinExpression("foo"));
assertConvertable(new LowerCaseExpression());
assertConvertable(new NormalizeExpression(new SimpleLinguistics()));
assertConvertable(new NowExpression());
assertConvertable(new OptimizePredicateExpression());
assertConvertable(new ParenthesisExpression(new InputExpression("foo")));
assertConvertable(new RandomExpression(69));
assertConvertable(new ScriptExpression(new StatementExpression(new InputExpression("foo"))));
assertConvertable(new SelectInputExpression(new Pair<String, Expression>("foo", new IndexExpression("bar")), new Pair<String, Expression>("bar", new IndexExpression("foo"))));
assertConvertable(new SetLanguageExpression());
assertConvertable(new SetValueExpression(new IntegerFieldValue(69)));
assertConvertable(new SetVarExpression("foo"));
assertConvertable(new SplitExpression("foo"));
assertConvertable(new StatementExpression(new InputExpression("foo")));
assertConvertable(new SubstringExpression(6, 9));
assertConvertable(new SummaryExpression("foo"));
assertConvertable(new SwitchExpression(Collections.singletonMap("foo", (Expression) new IndexExpression("bar")), new InputExpression("baz")));
assertConvertable(new ThisExpression());
assertConvertable(new ToArrayExpression());
assertConvertable(new ToByteExpression());
assertConvertable(new ToDoubleExpression());
assertConvertable(new ToFloatExpression());
assertConvertable(new ToIntegerExpression());
assertConvertable(new TokenizeExpression(new SimpleLinguistics(), new AnnotatorConfig()));
assertConvertable(new ToLongExpression());
assertConvertable(new ToPositionExpression());
assertConvertable(new ToStringExpression());
assertConvertable(new ToWsetExpression(false, false));
assertConvertable(new TrimExpression());
assertConvertable(new ZCurveExpression());
}
Aggregations