Search in sources :

Example 1 with StemMode

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

the class StemmingSearcher method search.

@Override
public Result search(Query query, Execution execution) {
    if (query.properties().getBoolean(DISABLE))
        return execution.search(query);
    IndexFacts.Session indexFacts = execution.context().getIndexFacts().newSession(query);
    Item newRoot = replaceTerms(query, indexFacts);
    query.getModel().getQueryTree().setRoot(newRoot);
    query.trace(getFunctionName(), true, 2);
    Highlight highlight = query.getPresentation().getHighlight();
    if (highlight != null) {
        Set<String> highlightFields = highlight.getHighlightItems().keySet();
        for (String field : highlightFields) {
            StemMode stemMode = indexFacts.getIndex(field).getStemMode();
            if (stemMode != StemMode.NONE) {
                Item newHighlight = scan(highlight.getHighlightItems().get(field), false, Language.ENGLISH, indexFacts, null);
                highlight.getHighlightItems().put(field, (AndItem) newHighlight);
            }
        }
    }
    return execution.search(query);
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) StemMode(com.yahoo.language.process.StemMode)

Example 2 with StemMode

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

the class StemmingSearcher method checkBlock.

private Item checkBlock(BlockItem b, boolean isCJK, Language language, IndexFacts.Session indexFacts, Map<Item, TaggableItem> reverseConnectivity) {
    if (b instanceof PrefixItem || !b.isWords())
        return (Item) b;
    if (b.isFromQuery() && !b.isStemmed()) {
        Index index = indexFacts.getIndex(b.getIndexName());
        StemMode stemMode = index.getStemMode();
        if (stemMode != StemMode.NONE)
            return stem(b, isCJK, language, reverseConnectivity, index);
    }
    return (Item) b;
}
Also used : Index(com.yahoo.prelude.Index) StemMode(com.yahoo.language.process.StemMode)

Example 3 with StemMode

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

the class AnnotatorConfigTestCase method requireThatAccessorsWork.

@Test
public void requireThatAccessorsWork() {
    AnnotatorConfig config = new AnnotatorConfig();
    for (Language language : Language.values()) {
        config.setLanguage(language);
        assertEquals(language, config.getLanguage());
    }
    for (StemMode mode : StemMode.values()) {
        config.setStemMode(mode);
        assertEquals(mode, config.getStemMode());
    }
    config.setRemoveAccents(true);
    assertTrue(config.getRemoveAccents());
    config.setRemoveAccents(false);
    assertFalse(config.getRemoveAccents());
}
Also used : Language(com.yahoo.language.Language) StemMode(com.yahoo.language.process.StemMode) Test(org.junit.Test)

Aggregations

StemMode (com.yahoo.language.process.StemMode)3 Language (com.yahoo.language.Language)1 Index (com.yahoo.prelude.Index)1 IndexFacts (com.yahoo.prelude.IndexFacts)1 Test (org.junit.Test)1