Search in sources :

Example 6 with Linguistics

use of com.yahoo.language.Linguistics in project vespa by vespa-engine.

the class NormalizeTestCase method requireThatHashCodeAndEqualsAreImplemented.

@Test
public void requireThatHashCodeAndEqualsAreImplemented() {
    Linguistics linguistics = new SimpleLinguistics();
    NormalizeExpression exp = new NormalizeExpression(linguistics);
    assertFalse(exp.equals(new Object()));
    assertFalse(exp.equals(new NormalizeExpression(Mockito.mock(Linguistics.class))));
    assertEquals(exp, new NormalizeExpression(linguistics));
    assertEquals(exp.hashCode(), new NormalizeExpression(linguistics).hashCode());
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Linguistics(com.yahoo.language.Linguistics) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Test(org.junit.Test)

Example 7 with Linguistics

use of com.yahoo.language.Linguistics in project vespa by vespa-engine.

the class NormalizeTestCase method requireThatAccessorsWork.

@Test
public void requireThatAccessorsWork() {
    Linguistics linguistics = new SimpleLinguistics();
    NormalizeExpression exp = new NormalizeExpression(linguistics);
    assertSame(linguistics, exp.getLinguistics());
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Linguistics(com.yahoo.language.Linguistics) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Test(org.junit.Test)

Example 8 with Linguistics

use of com.yahoo.language.Linguistics in project vespa by vespa-engine.

the class TokenizeTestCase method requireThatAccessorsWork.

@Test
public void requireThatAccessorsWork() {
    Linguistics linguistics = new SimpleLinguistics();
    AnnotatorConfig config = new AnnotatorConfig();
    TokenizeExpression exp = new TokenizeExpression(linguistics, config);
    assertSame(linguistics, exp.getLinguistics());
    assertSame(config, exp.getConfig());
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) AnnotatorConfig(com.yahoo.vespa.indexinglanguage.linguistics.AnnotatorConfig) Linguistics(com.yahoo.language.Linguistics) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Test(org.junit.Test)

Example 9 with Linguistics

use of com.yahoo.language.Linguistics in project vespa by vespa-engine.

the class LinguisticsAnnotatorTestCase method requireThatTokenizeCappingWorks.

@Test
public void requireThatTokenizeCappingWorks() {
    String shortString = "short string";
    SpanTree spanTree = new SpanTree(SpanTrees.LINGUISTICS);
    spanTree.setStringFieldValue(new StringFieldValue(shortString));
    spanTree.spanList().span(0, 5).annotate(new Annotation(AnnotationTypes.TERM));
    spanTree.spanList().span(6, 6).annotate(new Annotation(AnnotationTypes.TERM));
    StringFieldValue shortValue = new StringFieldValue(shortString);
    Linguistics linguistics = new SimpleLinguistics();
    LinguisticsAnnotator annotator = new LinguisticsAnnotator(linguistics, new AnnotatorConfig().setMaxTokenLength(12));
    assertTrue(annotator.annotate(shortValue));
    assertEquals(spanTree, shortValue.getSpanTree(SpanTrees.LINGUISTICS));
    assertEquals(shortString, shortValue.getSpanTree(SpanTrees.LINGUISTICS).getStringFieldValue().getString());
    StringFieldValue cappedValue = new StringFieldValue(shortString + " a longer string");
    assertTrue(annotator.annotate(cappedValue));
    assertEquals((shortString + " a longer string"), cappedValue.getSpanTree(SpanTrees.LINGUISTICS).getStringFieldValue().getString());
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) Linguistics(com.yahoo.language.Linguistics) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Annotation(com.yahoo.document.annotation.Annotation) SpanTree(com.yahoo.document.annotation.SpanTree) Test(org.junit.Test)

Example 10 with Linguistics

use of com.yahoo.language.Linguistics in project vespa by vespa-engine.

the class ExpressionTestCase method assertExpression.

private static void assertExpression(Class expectedClass, String str) throws ParseException {
    Linguistics linguistics = new SimpleLinguistics();
    Expression foo = Expression.fromString(str, linguistics);
    assertEquals(expectedClass, foo.getClass());
    Expression bar = Expression.fromString(foo.toString(), linguistics);
    assertEquals(foo.hashCode(), bar.hashCode());
    assertEquals(foo, bar);
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Linguistics(com.yahoo.language.Linguistics) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics)

Aggregations

Linguistics (com.yahoo.language.Linguistics)12 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)11 Test (org.junit.Test)9 Annotation (com.yahoo.document.annotation.Annotation)2 SpanTree (com.yahoo.document.annotation.SpanTree)2 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)2 Query (com.yahoo.search.Query)2 Language (com.yahoo.language.Language)1 Token (com.yahoo.language.process.Token)1 AndItem (com.yahoo.prelude.query.AndItem)1 WordItem (com.yahoo.prelude.query.WordItem)1 AnnotatorConfig (com.yahoo.vespa.indexinglanguage.linguistics.AnnotatorConfig)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1