Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 99c4f9ce authored by Thinh Dong's avatar Thinh Dong
Browse files

Updated GP with blank nodes

parent f1b20101
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@
package fr.inrialpes.exmo.align.impl.renderer;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
......@@ -86,6 +85,9 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
Alignment alignment = null;
Cell cell = null;
Hashtable<String,String> nslist = null;
protected boolean ignoreerrors = false;
protected static boolean blanks = false;
protected boolean weakens = false;
private String instance = null;
private String value = "";
......@@ -129,7 +131,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
public static void resetVariablesName(String s, String o) {
count = 1;
sub = "?" + s;
obj = "?" + o + count;
if ( blanks ) {
obj = "_:" + o + count;
}
else {
obj = "?" + o + count;
}
}
public void resetVariables(String s, String o) {
......@@ -389,7 +396,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
valueRestriction = null;
obj = temp;
if(op == Constructor.AND){
obj = "?o" + ++count;
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
}
}
}
......@@ -589,10 +601,17 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
size--;
if(size != 0){
sub = obj;
if(size == 1 && valueRestriction != null)
if( size == 1 && valueRestriction != null ) {
obj = "\"" + valueRestriction.toString() + "\"";
else
obj = "?o" + ++count;
}
else {
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
}
}
}
}
objectsRestriction.add(obj);
......@@ -614,7 +633,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
size--;
objectsRestriction.add(obj);
if(size != 0 && valueRestriction == null){
obj = "?o" + ++count;
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
}
}
}
}
......@@ -626,7 +650,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
}
}
op = null;
obj = "?o" + ++count;
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
}
}
// DONE
......@@ -861,8 +890,13 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
if(size == 1 && valueRestriction != null)
obj = valueRestriction.toString();
else {
obj = "?o" + ++count;
objectsRestriction.add(obj);
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
objectsRestriction.add(obj);
}
}
}
......@@ -952,7 +986,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
size--;
objectsRestriction.add(obj);
if(size != 0 && valueRestriction == null){
obj = "?o" + ++count;
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
}
}
}
}
......@@ -965,7 +1004,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
}
}
op = null;
obj = "?o" + ++count;
if ( blanks ) {
obj = "_:o" + ++count;
}
else {
obj = "?o" + ++count;
}
}
// DONE
......@@ -1065,7 +1109,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
index = e.getType().lastIndexOf("#");
else
index = e.getType().lastIndexOf("/");
datatype = e.getType().substring(0, index+1);
datatype = e.getType().substring(index+1);
}
}
......@@ -62,6 +62,12 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor
public void init(Properties p) {
if ( p.getProperty( "embedded" ) != null
&& !p.getProperty( "embedded" ).equals("") ) embedded = true;
if ( p.getProperty( "blanks" ) != null && !p.getProperty( "blanks" ).equals("") )
blanks = true;
if ( p.getProperty( "weakens" ) != null && !p.getProperty( "weakens" ).equals("") )
weakens = true;
if ( p.getProperty( "ignoreerrors" ) != null && !p.getProperty( "ignoreerrors" ).equals("") )
ignoreerrors = true;
split = ( p.getProperty( "split" ) != null && !p.getProperty( "split" ).equals("") );
if ( p.getProperty( "dir" ) != null && !p.getProperty( "dir" ).equals("") )
splitdir = p.getProperty( "dir" )+"/";
......@@ -110,11 +116,10 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor
query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL;
}
query += "CONSTRUCT {"+NL;
query += listBGP1.get(listBGP1.size()-1)+NL;
query += listBGP1.get(listBGP1.size()-1);
query += "}"+NL;
query += "WHERE {"+NL;
query += listBGP2.get(listBGP2.size()-1)+NL;
query += listBGP2.get(listBGP2.size()-1);
query += "}"+NL;
if( split ) {
createQueryFile( splitdir, query );
......@@ -125,7 +130,7 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor
query="";
/*
if(!listBGP2.get(listBGP2.size()-1).contains("UNION") &&
if(!listBGP2.get(listBGP2.size()-1).contains("UNION") &&
!listBGP2.get(listBGP2.size()-1).contains("FILTER") &&
!listBGP2.get(listBGP2.size()-1).contains("MINUS")){
for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) {
......
......@@ -57,6 +57,12 @@ public class SPARQLSelectRendererVisitor extends GraphPatternRendererVisitor imp
public void init(Properties p) {
if ( p.getProperty( "embedded" ) != null && !p.getProperty( "embedded" ).equals("") )
embedded = true;
if ( p.getProperty( "blanks" ) != null && !p.getProperty( "blanks" ).equals("") )
blanks = true;
if ( p.getProperty( "weakens" ) != null && !p.getProperty( "weakens" ).equals("") )
weakens = true;
if ( p.getProperty( "ignoreerrors" ) != null && !p.getProperty( "ignoreerrors" ).equals("") )
ignoreerrors = true;
split = ( p.getProperty( "split" ) != null && !p.getProperty( "split" ).equals("") );
if ( p.getProperty( "dir" ) != null && !p.getProperty( "dir" ).equals("") )
splitdir = p.getProperty( "dir" )+"/";
......@@ -89,37 +95,36 @@ public class SPARQLSelectRendererVisitor extends GraphPatternRendererVisitor imp
listCond1 = new ArrayList<String>(getCondition());
resetVariables("s", "o");
((Expression)(cell.getObject2())).accept( this );
listBGP2 = new ArrayList<String>(getBGP());
listCond2 = new ArrayList<String>(getCondition());
((Expression)(cell.getObject2())).accept( this );
listBGP2 = new ArrayList<String>(getBGP());
listCond2 = new ArrayList<String>(getCondition());
for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) {
String k = (String)e.nextElement();
query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL;
}
query += "SELECT ?s WHERE {"+NL;
query += listBGP1.get(listBGP1.size()-1)+NL;
query += "}"+NL;
if ( split ) {
createQueryFile( splitdir, query );
} else {
indentedOutputln(query);
}
query="";
for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) {
String k = (String)e.nextElement();
query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL;
}
query += "SELECT ?s WHERE {"+NL;
query += listBGP2.get(listBGP2.size()-1)+NL;
query += "}"+NL;
if ( split ) {
createQueryFile( splitdir, query );
} else {
indentedOutputln(query);
}
}
for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) {
String k = (String)e.nextElement();
query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL;
}
query += "SELECT ?s WHERE {"+NL;
query += listBGP1.get(listBGP1.size()-1);
query += "}"+NL;
if ( split ) {
createQueryFile( splitdir, query );
} else {
indentedOutputln(query);
}
query="";
for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) {
String k = (String)e.nextElement();
query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL;
}
query += "SELECT ?s WHERE {"+NL;
query += listBGP2.get(listBGP2.size()-1);
query += "}"+NL;
if ( split ) {
createQueryFile( splitdir, query );
} else {
indentedOutputln(query);
}
}
}
public void visit( Relation rel ) throws AlignmentException {
......
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