use of com.yahoo.prelude.semantics.engine.FlattenedItem in project vespa by vespa-engine.
the class ConditionReference method automataMatch.
private boolean automataMatch(RuleEvaluation e) {
FlattenedItem current = e.currentItem();
if (current == null)
return false;
Object annotation = current.getItem().getAnnotation(conditionName);
if (annotation == null)
return false;
if (!(annotation instanceof PhraseMatcher.Phrase))
return false;
PhraseMatcher.Phrase phrase = (PhraseMatcher.Phrase) annotation;
Choicepoint choicePoint = e.getChoicepoint(this, true);
boolean matches = automataMatchPhrase(phrase, e);
if (!matches && e.isInNegation()) {
// TODO: Temporary hack! Works for single items only
e.addMatch(current, null);
}
if ((!matches && !e.isInNegation() || (matches && e.isInNegation())))
choicePoint.backtrackPosition();
return matches;
}
use of com.yahoo.prelude.semantics.engine.FlattenedItem in project vespa by vespa-engine.
the class ConditionReference method automataMatchPhrase.
private boolean automataMatchPhrase(PhraseMatcher.Phrase phrase, RuleEvaluation e) {
for (PhraseMatcher.Phrase.MatchIterator i = phrase.itemIterator(); i.hasNext(); ) {
i.next();
FlattenedItem current = e.currentItem();
if (current == null)
return false;
if (!labelMatches(e.currentItem().getItem(), e))
return false;
if (!e.isInNegation())
e.addMatch(current, i.getReplace());
e.next();
}
// The underlying composite item has changed
if (phrase.getLength() > phrase.getBackedLength())
return false;
return true;
}
use of com.yahoo.prelude.semantics.engine.FlattenedItem in project vespa by vespa-engine.
the class Condition method labelMatches.
/**
* Whether the label matches the current item, true if there is no current item
*/
protected boolean labelMatches(RuleEvaluation e) {
FlattenedItem flattenedItem = e.currentItem();
if (flattenedItem == null)
return true;
TermItem item = flattenedItem.getItem();
if (item == null)
return true;
return labelMatches(item, e);
}
Aggregations