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());
}
}
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());
}
}
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());
}
}
Aggregations