Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 71b15d97 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- Improved (largely) SPARQLLinker rendering, added sameAs equality

parent baa94ac5
No related branches found
No related tags found
No related merge requests found
......@@ -80,8 +80,7 @@ with a warning:
<h2>Version 4.8 (2097): 2015-11-20 - Ant&eacute;sine</h2>
<p>The Alignment API is now compiled in Java 1.8 (it will not compile
in 1.7: please provide feedback if you need it in 1.7).</p>
<p>The Alignment API is now compiled in Java 1.8 (it will not compile in 1.7: please provide feedback if you need it in 1.7).</p>
<p><ul compact="1">
<li>Fixed a bug in pool aggregation (impl)</li>
......@@ -400,11 +399,8 @@ with a warning:
<p><span style="color: red;">BEWARE:</span>
Java WordNet Library (JWNL) has been upgraded to version 1.4.1rc2 (from 1.3rc3). This is included in the lib directory.
Hence, it is necessary to use WordNet-3.0 (the jwnl part will not work
anymore with 2.0).
If you want to stay with WordNet-2.0, you need to replace the jwnl.jar
library by the older one and this will work. However, using WordNet
with the Alignment API is not compulsory.
Hence, it is necessary to use WordNet-3.0 (the jwnl part will not work anymore with 2.0).
If you want to stay with WordNet-2.0, you need to replace the jwnl.jar library by the older one and this will work. However, using WordNet with the Alignment API is not compulsory.
</p>
<p>
<ul compact="1">
......
......@@ -74,6 +74,8 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im
boolean select = false;
boolean generateSameAs = false;
boolean requestedblanks = false;
private String content_Corese = ""; // resulting string for Corese
......@@ -101,9 +103,13 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im
if ( p.getProperty("graphName2") != null ) {
setGraph2Name( p.getProperty("graphName2") );
}
if ( p.getProperty("select") != null && !p.getProperty("select").equals("") ) {
if ( p.getProperty("select") != null ) {
select = true;
} else {
}
if ( p.getProperty("sameAs") != null ) {
generateSameAs = true;
}
if ( generateSameAs || !select ) {
prefixList.put("http://www.w3.org/2002/07/owl#", "owl");
}
......@@ -255,26 +261,48 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im
/**
* Generate the constraint corresponding to:
* MINUS SELECT ?x ?y WHERE { ?x pj ?wj . FILTER NOT EXISTS { ?y qj ?wj . } }
* MINUS SELECT ?x ?y WHERE { ?y qj ?wj . FILTER NOT EXISTS { ?x pj ?wj . } }
* MINUS { ?x pj ?wj . FILTER NOT EXISTS { ?y qj ?wj . } }
* MINUS { ?y qj ?wj . FILTER NOT EXISTS { ?x pj ?wj . } }
* Unfortunately with real link keys it should be (for w1 w2 initially selected):
* MINUS { ?x pj ?w3 . FILTER ( NOT ( EXISTS { ?y qj ?w4 . } && lcase(str(?w3)) = lcase(str(?w4)) )) }
* MINUS { ?y qj ?w5 . FILTER ( NOT ( EXISTS { ?x pj ?w6 . } && lcase(str(?w6)) = lcase(str(?w5)) )) }
*/
public void visit( final LinkkeyEquals linkkeyEquals ) throws AlignmentException {
// In the semantics of EQ-Linkkeys, the intersection must not be empty...
processInLinkKey( linkkeyEquals );
initStructure(); //strBGP = ""; // congrats! Unsure
String o1 = createVarName();
resetVariables( "?s1", o1 );
linkkeyEquals.getExpression1().accept( this );
String temp = obj;
String GP1 = wrapInNamedGraph( onto1NamedGraph, getGP() );
initStructure(); //strBGP = ""; // congrats!
resetVariables( "?s2", o1 );
obj = temp;
linkkeyEquals.getExpression2().accept( this );
String GP2 = wrapInNamedGraph( onto2NamedGraph, getGP() );
lkpattern += "MINUS { " + GP1 + " FILTER NOT EXISTS { " + GP2 + " } }"+NL;
lkpattern += "MINUS { " + GP2 + " FILTER NOT EXISTS { " + GP1 + " } }"+NL;
// Because virtoso insist on having extravar2 bound in the WHERE clause of the query, we have to add this...
if ( (linkkeyEquals.getExpression1() instanceof PropertyExpression) || (linkkeyEquals.getExpression2() instanceof PropertyExpression) ) { // Literal values
//initStructure(); //strBGP = ""; // congrats! Unsure
emptyGP();
String o1 = createVarName();
resetVariables( "?s1", o1 );
linkkeyEquals.getExpression1().accept( this );
String GP1 = wrapInNamedGraph( onto1NamedGraph, getGP() );
//initStructure(); //strBGP = ""; // congrats!
emptyGP();
String o2 = createVarName();
resetVariables( "?s2", o2 );
linkkeyEquals.getExpression2().accept( this );
String GP2 = wrapInNamedGraph( onto2NamedGraph, getGP() );
// The two patterns are independent so can use the same variables
lkpattern += "MINUS { " + GP1 + "FILTER NOT EXISTS { "+ GP2 +" FILTER ( "+equalValueFilterStatement( o1, o2 )+" ) } }"+NL;
lkpattern += "MINUS { " + GP2 + "FILTER NOT EXISTS { "+ GP1 +" FILTER ( "+equalValueFilterStatement( o1, o2 )+" ) } }"+NL;
} else if ( generateSameAs ) { // should be the same...
} else {
initStructure(); //strBGP = ""; // congrats! Unsure
emptyGP();
String o1 = createVarName();
resetVariables( "?s1", o1 );
linkkeyEquals.getExpression1().accept( this );
String temp = obj;
String GP1 = wrapInNamedGraph( onto1NamedGraph, getGP() );
initStructure(); //strBGP = ""; // congrats!
resetVariables( "?s2", temp );
linkkeyEquals.getExpression2().accept( this );
String GP2 = wrapInNamedGraph( onto2NamedGraph, getGP() );
// The two patterns are independent so can use the same variables
lkpattern += "MINUS { " + GP1 + " FILTER NOT EXISTS { " + GP2 + " } }"+NL;
lkpattern += "MINUS { " + GP2 + " FILTER NOT EXISTS { " + GP1 + " } }"+NL;
}
}
public void visit( final LinkkeyIntersects linkkeyIntersects ) throws AlignmentException {
......@@ -294,7 +322,22 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im
resetVariables( lkvar2, o2 );
binding.getExpression2().accept( this );
lkpattern += wrapInNamedGraph( onto2NamedGraph, getGP() );
lkpattern += "FILTER( lcase(str("+o1+")) = lcase(str("+o2+")) )"+NL;
lkpattern += "FILTER ( "+equalValueFilterStatement( o1, o2 )+" )"+NL;
//"FILTER( lcase(str("+o1+")) = lcase(str("+o2+")) )"+NL;
} else if ( generateSameAs ) {
// Relations
emptyGP();
String o1 = createVarName();
resetVariables( lkvar1, o1 );
binding.getExpression1().accept( this );
lkpattern += wrapInNamedGraph( onto1NamedGraph, getGP() );
emptyGP();
String o2 = createVarName();
resetVariables( lkvar2, o2 );
binding.getExpression2().accept( this );
lkpattern += wrapInNamedGraph( onto2NamedGraph, getGP() );
lkpattern += "FILTER ( "+equalObjectFilterStatement( o1, o2 )+" )"+NL;
//o1+" owl:sameAs "+o2+"."+NL+" UNION FILTER( "+o1+" = "+o2+" )"+NL;
} else {
//?x p'i ?zi . ?y q'i ?zi .
emptyGP();
......@@ -309,6 +352,16 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im
}
}
// There could be two options, test which one is fastest to evaluate...
protected String equalObjectFilterStatement ( String o1, String o2 ) {
//return o1+" owl:sameAs "+o2+". UNION FILTER( "+o1+" = "+o2+" )";
return o1+" = "+o2+" || EXISTS { "+o1+" owl:sameAs "+o2+" . }";
}
protected String equalValueFilterStatement ( String o1, String o2 ) {
return "lcase(str("+o1+")) = lcase(str("+o2+"))";
}
protected String wrapInNamedGraph( String namedGraph, String stuff ) {
if ( namedGraph != null ) {
return "GRAPH <" + namedGraph + "> {" + NL + stuff + "}" + NL ;
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment