Package org.aksw.jenax.arq.util.expr
Class CnfUtils
java.lang.Object
org.aksw.jenax.arq.util.expr.CnfUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<org.apache.jena.sparql.expr.ExprList>cnfToClauses(Iterable<org.apache.jena.sparql.expr.Expr> exprs) This method only words if the input expressions are in DNF, otherwise you will likely get junk back.static voidcollectAnd(org.apache.jena.sparql.expr.Expr expr, List<org.apache.jena.sparql.expr.ExprList> list) static voidcollectOr(org.apache.jena.sparql.expr.Expr expr, org.apache.jena.sparql.expr.ExprList list) static org.apache.jena.sparql.expr.Expreval(org.apache.jena.sparql.expr.Expr expr) static Map.Entry<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> extractEquality(Collection<? extends org.apache.jena.sparql.expr.Expr> clause) static Map<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> getConstants(Iterable<? extends Collection<? extends org.apache.jena.sparql.expr.Expr>> cnf, boolean suppressConflicts) Extract from the CNF all mappings from a variable to constant, i.e.static <E extends org.apache.jena.sparql.expr.Expr,C extends Collection<? extends E>>
Set<C>getEqualityClauses(Iterable<C> cnf) static org.apache.jena.sparql.expr.Exprhandle(org.apache.jena.sparql.expr.ExprFunction expr) static booleanisSubsumedBy(Set<Set<org.apache.jena.sparql.expr.Expr>> cand, Set<Set<org.apache.jena.sparql.expr.Expr>> ref) Test if the candidate is subsumed by the reference.static <T extends org.apache.jena.sparql.expr.ExprFunction2>
Tnormalize(T expr) Returns the input unchanged, unless it is (const op var) which becomes (var op const).static List<org.apache.jena.sparql.expr.ExprList>toClauses(org.apache.jena.sparql.expr.Expr expr) static List<org.apache.jena.sparql.expr.ExprList>toClauses(org.apache.jena.sparql.expr.ExprList exprs) static org.apache.jena.sparql.expr.Exprstatic org.apache.jena.sparql.expr.ExprListtoExprList(Iterable<Set<org.apache.jena.sparql.expr.Expr>> cnf) toSetCnf(org.apache.jena.sparql.expr.Expr expr) toSetCnf(org.apache.jena.sparql.expr.ExprList exprs) Return a sub cnf that where each element of a clause contains all variables
-
Constructor Details
-
CnfUtils
public CnfUtils()
-
-
Method Details
-
normalize
public static <T extends org.apache.jena.sparql.expr.ExprFunction2> T normalize(T expr) Returns the input unchanged, unless it is (const op var) which becomes (var op const). Use for (in-)equalities. -
extractEquality
public static Map.Entry<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> extractEquality(Collection<? extends org.apache.jena.sparql.expr.Expr> clause) -
getEqualityClauses
public static <E extends org.apache.jena.sparql.expr.Expr,C extends Collection<? extends E>> Set<C> getEqualityClauses(Iterable<C> cnf) -
getConstants
public static Map<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> getConstants(Iterable<? extends Collection<? extends org.apache.jena.sparql.expr.Expr>> cnf, boolean suppressConflicts) Extract from the CNF all mappings from a variable to constant, i.e. if there is ?x = foo, then the result will contain the mapping ?x -> foo. If there are conflicting mappings, return an arbitrary one. The idea is, that using these mappings, one can evaluate remaining expressions. In the case of conflicts, these will simply evaluate to FALSE.- Parameters:
cnf-- Returns:
-
toExpr
-
toExprList
-
isSubsumedBy
public static boolean isSubsumedBy(Set<Set<org.apache.jena.sparql.expr.Expr>> cand, Set<Set<org.apache.jena.sparql.expr.Expr>> ref) Test if the candidate is subsumed by the reference. This means that the candidate must contain at least all constraints of ref- Parameters:
cand-ref-- Returns:
-
toSetCnf
public static Set<Set<org.apache.jena.sparql.expr.Expr>> toSetCnf(org.apache.jena.sparql.expr.ExprList exprs) Return a sub cnf that where each element of a clause contains all variables- Parameters:
clauses-requiredVars-- Returns:
-
toSetCnf
-
toClauses
public static List<org.apache.jena.sparql.expr.ExprList> toClauses(org.apache.jena.sparql.expr.Expr expr) -
toClauses
public static List<org.apache.jena.sparql.expr.ExprList> toClauses(org.apache.jena.sparql.expr.ExprList exprs) -
cnfToClauses
public static List<org.apache.jena.sparql.expr.ExprList> cnfToClauses(Iterable<org.apache.jena.sparql.expr.Expr> exprs) This method only words if the input expressions are in DNF, otherwise you will likely get junk back.- Parameters:
exprs-- Returns:
-
collectAnd
public static void collectAnd(org.apache.jena.sparql.expr.Expr expr, List<org.apache.jena.sparql.expr.ExprList> list) -
collectOr
public static void collectOr(org.apache.jena.sparql.expr.Expr expr, org.apache.jena.sparql.expr.ExprList list) -
eval
public static org.apache.jena.sparql.expr.Expr eval(org.apache.jena.sparql.expr.Expr expr) -
handle
public static org.apache.jena.sparql.expr.Expr handle(org.apache.jena.sparql.expr.ExprFunction expr)
-