Search in sources :

Example 11 with Linguistics

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

the class NGramTestCase method requireThatHashCodeAndEqualsAreImplemented.

@Test
public void requireThatHashCodeAndEqualsAreImplemented() {
    Linguistics linguistics = new SimpleLinguistics();
    NGramExpression exp = new NGramExpression(linguistics, 69);
    assertFalse(exp.equals(new Object()));
    assertFalse(exp.equals(new NGramExpression(Mockito.mock(Linguistics.class), 96)));
    assertFalse(exp.equals(new NGramExpression(linguistics, 96)));
    assertEquals(exp, new NGramExpression(linguistics, 69));
    assertEquals(exp.hashCode(), new NGramExpression(new SimpleLinguistics(), 69).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 12 with Linguistics

use of com.yahoo.language.Linguistics 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());
}
Also used : SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Query(com.yahoo.search.Query) Linguistics(com.yahoo.language.Linguistics) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) Test(org.junit.Test)

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