public static String generateExactMatchPattern ( URI origin , URI destination , String bindingVar , boolean includeUrisBound ) { List < String > patterns = new ArrayList < String > ( ) ; // Exact match pattern StringBuffer query = new StringBuffer ( ) ; query . append ( Util . generateSubclassPattern ( origin , destination ) + NL ) ; query . append ( Util . generateSuperclassPattern ( origin , destination ) + NL ) ; patterns . add ( query . toString ( ) ) ; // Find same term cases query = new StringBuffer ( ) ; query . append ( "FILTER (str(" ) . append ( sparqlWrapUri ( origin ) ) . append ( ") = str(" ) . append ( sparqlWrapUri ( destination ) ) . append ( ") ) . " + NL ) ; patterns . add ( query . toString ( ) ) ; StringBuffer result = new StringBuffer ( generateUnionStatement ( patterns ) ) ; // Bind a variable for inspection result . append ( "BIND (true as ?" + bindingVar + ") ." + NL ) ; // Include origin and destination in the returned bindings if requested if ( includeUrisBound ) { result . append ( "BIND (" ) . append ( sparqlWrapUri ( origin ) ) . append ( " as ?origin) ." ) . append ( NL ) ; result . append ( "BIND (" ) . append ( sparqlWrapUri ( destination ) ) . append ( " as ?destination) ." ) . append ( NL ) ; } return result . toString ( ) ; }
Generate a pattern for check if two concepts have an exact match . Basically we look for either identical classes or equivalent ones Uses BIND which Requires SPARQL 1 . 1