Search in sources :

Example 1 with Match

use of com.yahoo.prelude.semantics.engine.Match in project vespa by vespa-engine.

the class LiteralTermProduction method produce.

public void produce(RuleEvaluation e, int offset) {
    WordItem newItem = new WordItem(literal, getLabel());
    if (replacing) {
        Match matched = e.getNonreferencedMatch(0);
        insertMatch(e, matched, newItem, offset);
    } else {
        newItem.setWeight(getWeight());
        if (e.getTraceLevel() >= 6)
            e.trace(6, "Adding '" + newItem + "'");
        e.addItem(newItem, getTermType());
    }
}
Also used : WordItem(com.yahoo.prelude.query.WordItem) Match(com.yahoo.prelude.semantics.engine.Match)

Example 2 with Match

use of com.yahoo.prelude.semantics.engine.Match in project vespa by vespa-engine.

the class LiteralPhraseProduction method produce.

public void produce(RuleEvaluation e, int offset) {
    PhraseItem newPhrase = new PhraseItem();
    newPhrase.setIndexName(getLabel());
    for (String term : terms) newPhrase.addItem(new WordItem(term));
    if (replacing) {
        Match matched = e.getNonreferencedMatch(0);
        insertMatch(e, matched, newPhrase, offset);
    } else {
        newPhrase.setWeight(getWeight());
        if (e.getTraceLevel() >= 6)
            e.trace(6, "Adding '" + newPhrase + "'");
        e.addItem(newPhrase, getTermType());
    }
}
Also used : WordItem(com.yahoo.prelude.query.WordItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) Match(com.yahoo.prelude.semantics.engine.Match)

Example 3 with Match

use of com.yahoo.prelude.semantics.engine.Match in project vespa by vespa-engine.

the class ReplacingProductionRule method removeNonreferencedMatches.

/**
 * Remove items until there's only one item left
 */
private void removeNonreferencedMatches(RuleEvaluation e) {
    int itemCount = e.getEvaluation().getQuerySize();
    // Remove items backwards to ease index handling
    for (int i = e.getNonreferencedMatchCount() - 1; i >= 0; i--) {
        // Ensure we don't produce an empty query
        if (getProduction().getTermCount() == 0 && itemCount == 1)
            break;
        itemCount--;
        Match match = e.getNonreferencedMatch(i);
        match.getItem().getParent().removeItem(match.getPosition());
    }
}
Also used : Match(com.yahoo.prelude.semantics.engine.Match)

Aggregations

Match (com.yahoo.prelude.semantics.engine.Match)3 WordItem (com.yahoo.prelude.query.WordItem)2 PhraseItem (com.yahoo.prelude.query.PhraseItem)1