querqy.rewrite.commonrules.model.RulesCollection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querqy-core Show documentation
Show all versions of querqy-core Show documentation
Querqy library for query rewriting: Querqy Core
package querqy.rewrite.commonrules.model;
import java.util.Set;
import java.util.stream.Collectors;
import querqy.model.InputSequenceElement;
import querqy.rewrite.commonrules.select.TopRewritingActionCollector;
public interface RulesCollection {
/**
* Find and return all rewrite actions for an input sequence
* @param sequence The input sequence
* @param collector The collector of rewriting actions
*/
void collectRewriteActions(PositionSequence sequence, TopRewritingActionCollector collector);
/**
*
* Get a collection of all instructions from the rules of this RulesCollection
*
* @return The set of instructions
*/
Set getInstructions();
/**
* Get all {@link querqy.model.Term}s that will be generated by this RulesCollection. This only includes terms
* that are known from the configuration. The terms returned from this method might be used to optimise caching.
*
* @return The terms generated by the right-hand sides of the instructions.
*/
default Set getGenerableTerms() {
return getInstructions().stream()
.flatMap(instruction -> instruction.getGenerableTerms().stream())
.collect(Collectors.toSet());
}
}