/** * Checks whether sub is subsumed by sup * * @param sub * @param sup * @return */ public static boolean isSubsumedBy(final Query sub, final Query sup) { return !getSubsumptionMappings(sub, sup).isEmpty(); }
/** * Checks whether sub is subsumed by sup * * @param sub * @param sup * @return */ public static boolean isSubsumedBy(final Query sub, final Query sup) { return !getSubsumptionMappings(sub, sup).isEmpty(); }
/** * Checks whether sub is subsumed by sup * * @param sub * @param sup * @return */ public static boolean isSubsumedBy(final Query sub, final Query sup) { return !getSubsumptionMappings(sub, sup).isEmpty(); }
/** * The subsumption in this example holds because of the subproperty relation between hasBrother and hasSibling. however, The second query uses the variable * name ?z instead of the the variable name ?y used in the first query. The query subsumption algorithm finds the mapping between query variables. */ public void example4() { final Query q7 = query("?x a family:Female; family:hasBrother ?y . "); final Query q8 = query("?x a family:Female; family:hasSibling ?z ."); System.out.println("Example 4"); System.out.println("========="); System.out.println("Query 7: " + q7.toString()); System.out.println("Query 8: " + q8.toString()); System.out.println(); System.out.println("Query 7 is subsumed by query 8: " + QuerySubsumption.isSubsumedBy(q7, q8)); System.out.print("Subsumption mappings: "); final QueryResult mappings = QuerySubsumption.getSubsumptionMappings(q7, q8); for (final ResultBinding mapping : mappings) for (final Iterator<?> j = q8.getVars().iterator(); j.hasNext();) { final ATermAppl var = (ATermAppl) j.next(); System.out.print(var.getArgument(0) + " -> " + mapping.getValue(var)); //I get var(x) as opposed to x if (j.hasNext()) System.out.print(", "); } System.out.println(); } }
/** * The subsumption in this example holds because of the subproperty relation between hasBrother and hasSibling. however, The second query uses the variable * name ?z instead of the the variable name ?y used in the first query. The query subsumption algorithm finds the mapping between query variables. */ public void example4() { final Query q7 = query("?x a family:Female; family:hasBrother ?y . "); final Query q8 = query("?x a family:Female; family:hasSibling ?z ."); System.out.println("Example 4"); System.out.println("========="); System.out.println("Query 7: " + q7.toString()); System.out.println("Query 8: " + q8.toString()); System.out.println(); System.out.println("Query 7 is subsumed by query 8: " + QuerySubsumption.isSubsumedBy(q7, q8)); System.out.print("Subsumption mappings: "); final QueryResult mappings = QuerySubsumption.getSubsumptionMappings(q7, q8); for (final ResultBinding mapping : mappings) for (final Iterator<?> j = q8.getVars().iterator(); j.hasNext();) { final ATermAppl var = (ATermAppl) j.next(); System.out.print(var.getArgument(0) + " -> " + mapping.getValue(var)); //I get var(x) as opposed to x if (j.hasNext()) System.out.print(", "); } System.out.println(); } }