use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class ExpressionVisitorTestCase method requireThatAllExpressionsAreVisited.
@SuppressWarnings("unchecked")
@Test
public void requireThatAllExpressionsAreVisited() {
assertCount(3, new ArithmeticExpression(new InputExpression("foo"), ArithmeticExpression.Operator.ADD, new InputExpression("bar")));
assertCount(1, new AttributeExpression("foo"));
assertCount(1, new Base64DecodeExpression());
assertCount(1, new Base64EncodeExpression());
assertCount(3, new CatExpression(new InputExpression("foo"), new IndexExpression("bar")));
assertCount(1, new ClearStateExpression());
assertCount(1, new EchoExpression());
assertCount(2, new ForEachExpression(new IndexExpression("foo")));
assertCount(1, new GetFieldExpression("foo"));
assertCount(1, new GetVarExpression("foo"));
assertCount(2, new GuardExpression(new IndexExpression("foo")));
assertCount(1, new HexDecodeExpression());
assertCount(1, new HexEncodeExpression());
assertCount(1, new HostNameExpression());
assertCount(5, new IfThenExpression(new InputExpression("foo"), IfThenExpression.Comparator.EQ, new InputExpression("bar"), new IndexExpression("baz"), new IndexExpression("cox")));
assertCount(1, new IndexExpression("foo"));
assertCount(1, new InputExpression("foo"));
assertCount(1, new JoinExpression("foo"));
assertCount(1, new LowerCaseExpression());
assertCount(1, new NormalizeExpression(new SimpleLinguistics()));
assertCount(1, new NowExpression());
assertCount(1, new OptimizePredicateExpression());
assertCount(2, new ParenthesisExpression(new InputExpression("foo")));
assertCount(1, new RandomExpression(69));
assertCount(3, new ScriptExpression(new StatementExpression(new InputExpression("foo"))));
assertCount(3, new SelectInputExpression(new Pair<String, Expression>("foo", new IndexExpression("bar")), new Pair<String, Expression>("bar", new IndexExpression("foo"))));
assertCount(1, new SetLanguageExpression());
assertCount(1, new SetValueExpression(new IntegerFieldValue(69)));
assertCount(1, new SetVarExpression("foo"));
assertCount(1, new SplitExpression("foo"));
assertCount(2, new StatementExpression(new InputExpression("foo")));
assertCount(1, new SummaryExpression("foo"));
assertCount(1, new SubstringExpression(6, 9));
assertCount(3, new SwitchExpression(Collections.singletonMap("foo", (Expression) new IndexExpression("bar")), new InputExpression("baz")));
assertCount(1, new ThisExpression());
assertCount(1, new ToArrayExpression());
assertCount(1, new ToByteExpression());
assertCount(1, new ToDoubleExpression());
assertCount(1, new ToFloatExpression());
assertCount(1, new ToIntegerExpression());
assertCount(1, new TokenizeExpression(new SimpleLinguistics(), new AnnotatorConfig()));
assertCount(1, new ToLongExpression());
assertCount(1, new ToPositionExpression());
assertCount(1, new ToStringExpression());
assertCount(1, new ToWsetExpression(false, false));
assertCount(1, new TrimExpression());
assertCount(1, new ZCurveExpression());
}
use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class ExecutionContextTestCase method requireThatLanguageCanBeResolved.
@Test
public void requireThatLanguageCanBeResolved() {
ExecutionContext ctx = new ExecutionContext();
ctx.setValue(new StringFieldValue("\u3072\u3089\u304c\u306a"));
assertEquals(Language.JAPANESE, ctx.resolveLanguage(new SimpleLinguistics()));
ctx.setValue(new StringFieldValue("\ud55c\uae00\uacfc"));
assertEquals(Language.KOREAN, ctx.resolveLanguage(new SimpleLinguistics()));
}
use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class ExecutionContextTestCase method requireThatExplicitLanguagePreventsDetection.
@Test
public void requireThatExplicitLanguagePreventsDetection() {
ExecutionContext ctx = new ExecutionContext();
ctx.setLanguage(Language.ARABIC);
ctx.setValue(new StringFieldValue("\u3072\u3089\u304c\u306a"));
assertEquals(Language.ARABIC, ctx.resolveLanguage(new SimpleLinguistics()));
ctx.setValue(new StringFieldValue("\ud55c\uae00\uacfc"));
assertEquals(Language.ARABIC, ctx.resolveLanguage(new SimpleLinguistics()));
}
use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class NormalizeTestCase method requireThatInputIsNormalized.
@Test
public void requireThatInputIsNormalized() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setLanguage(Language.ENGLISH);
ctx.setValue(new StringFieldValue("b\u00e9yonc\u00e8"));
new NormalizeExpression(new SimpleLinguistics()).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("beyonce", ((StringFieldValue) val).getString());
}
use of com.yahoo.language.simple.SimpleLinguistics in project vespa by vespa-engine.
the class NGramTestCase method requireThatExpressionCanBeVerified.
@Test
public void requireThatExpressionCanBeVerified() {
Expression exp = new NGramExpression(new SimpleLinguistics(), 69);
assertVerify(DataType.STRING, exp, DataType.STRING);
assertVerifyThrows(null, exp, "Expected string input, got null.");
assertVerifyThrows(DataType.INT, exp, "Expected string input, got int.");
}
Aggregations