Mentions légales du service

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

- improved the SILK output (id, Filter, DataSource, LinkageRules)

parent c85aa34f
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,10 @@ import org.semanticweb.owl.align.AlignmentVisitor; ...@@ -28,7 +28,10 @@ import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Relation;
import fr.inrialpes.exmo.ontowrap.Ontology;
import fr.inrialpes.exmo.align.impl.Namespace; import fr.inrialpes.exmo.align.impl.Namespace;
import fr.inrialpes.exmo.align.impl.BasicAlignment;
import fr.inrialpes.exmo.align.impl.edoal.Expression; import fr.inrialpes.exmo.align.impl.edoal.Expression;
import java.net.URI; import java.net.URI;
...@@ -48,6 +51,9 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements ...@@ -48,6 +51,9 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements
private boolean ignoreerrors = false; private boolean ignoreerrors = false;
private boolean blanks = false; private boolean blanks = false;
private boolean weakens = false; private boolean weakens = false;
private String threshold = "";
private String limit = "";
private Random rand;
private static Namespace DEF = Namespace.ALIGNMENT; private static Namespace DEF = Namespace.ALIGNMENT;
...@@ -74,10 +80,17 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements ...@@ -74,10 +80,17 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements
weakens = true; weakens = true;
if ( p.getProperty( "ignoreerrors" ) != null && !p.getProperty( "ignoreerrors" ).equals("") ) if ( p.getProperty( "ignoreerrors" ) != null && !p.getProperty( "ignoreerrors" ).equals("") )
ignoreerrors = true; ignoreerrors = true;
if ( p.getProperty( "silkthreshold" ) != null && !p.getProperty( "silkthreshold" ).equals("") ) {
threshold = " threshold=\""+p.getProperty( "silkthreshold" )+"\"";
}
if ( p.getProperty( "silklimit" ) != null && !p.getProperty( "silklimit" ).equals("") ) {
limit = " limit=\""+p.getProperty( "silklimit" )+"\"";
}
if ( p.getProperty( "indent" ) != null ) if ( p.getProperty( "indent" ) != null )
INDENT = p.getProperty( "indent" ); INDENT = p.getProperty( "indent" );
if ( p.getProperty( "newline" ) != null ) if ( p.getProperty( "newline" ) != null )
NL = p.getProperty( "newline" ); NL = p.getProperty( "newline" );
rand = new Random( System.currentTimeMillis() );
} }
public void visit(Alignment align) throws AlignmentException { public void visit(Alignment align) throws AlignmentException {
...@@ -108,7 +121,7 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements ...@@ -108,7 +121,7 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements
} }
if ( embedded == false ) { if ( embedded == false ) {
writer.print("<?xml version='1.0' encoding='utf-8"); writer.print("<?xml version='1.0' encoding='utf-8");
writer.print("' standalone='no'?>"+NL); writer.print("' standalone='no'?>"+NL+NL);
} }
indentedOutputln("<SILK>"); indentedOutputln("<SILK>");
increaseIndent(); increaseIndent();
...@@ -125,6 +138,17 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements ...@@ -125,6 +138,17 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements
indentedOutputln("</Prefixes>"+NL); indentedOutputln("</Prefixes>"+NL);
indentedOutputln("<DataSources>"); indentedOutputln("<DataSources>");
increaseIndent(); increaseIndent();
indentedOutputln("<!-- These may have to be edited to proper data sources -->");
if ( align instanceof BasicAlignment ) {
printOntology( ((BasicAlignment)align).getOntologyObject1(), "source" );
} else {
printBasicOntology( align.getOntology1URI(), align.getFile1(), "source" );
}
if ( align instanceof BasicAlignment ) {
printOntology( ((BasicAlignment)align).getOntologyObject2(), "target" );
} else {
printBasicOntology( align.getOntology2URI(), align.getFile2(), "target" );
}
decreaseIndent(); decreaseIndent();
indentedOutputln("</DataSources>"+NL); indentedOutputln("</DataSources>"+NL);
indentedOutputln("<Interlinks>"); indentedOutputln("<Interlinks>");
...@@ -134,19 +158,34 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements ...@@ -134,19 +158,34 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements
indentedOutputln("</Interlinks>"); indentedOutputln("</Interlinks>");
decreaseIndent(); decreaseIndent();
writer.print("</SILK>"+NL); writer.print("</SILK>"+NL);
} }
public void visit(Cell cell) throws AlignmentException { private void printBasicOntology ( URI u, URI f, String function ) {
indentedOutput("<DataSource id=\""+function+"\" type=\"file\">"+NL);
increaseIndent();
if ( f != null ) {
indentedOutputln("<Param name=\"file\" value=\""+f+"\" />");
} else {
indentedOutputln("<Param name=\"file\" value=\""+u+"\" />");
}
indentedOutputln("<Param name=\"format\" value=\"RDF/XML\" />");
decreaseIndent();
indentedOutputln("</DataSource>");
}
public void printOntology( Ontology onto, String function ) {
URI u = onto.getURI();
URI f = onto.getFile();
printBasicOntology( u, f, function );
}
public void visit( Cell cell ) throws AlignmentException {
if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return; if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return;
// default behaviour // default behaviour
this.cell = cell; this.cell = cell;
// JE: must be improved because this is an URI // JE: cannot use Cell id because it is an URI and not an id
String id = cell.getId(); String id = "RandomId"+Math.abs( rand.nextInt(100000) );
if ( id == null || id.equals("") ){
Random rand = new Random(System.currentTimeMillis());
id = "RandomId"+Math.abs(rand.nextInt(1000));
}
URI u1 = cell.getObject1AsURI(alignment); URI u1 = cell.getObject1AsURI(alignment);
URI u2 = cell.getObject2AsURI(alignment); URI u2 = cell.getObject2AsURI(alignment);
...@@ -171,35 +210,49 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements ...@@ -171,35 +210,49 @@ public class SILKRendererVisitor extends GraphPatternRendererVisitor implements
tempList = new ArrayList<String>(getCondition()); tempList = new ArrayList<String>(getCondition());
listCond2 = new ArrayList<String>(tempList); listCond2 = new ArrayList<String>(tempList);
// JE: The link id should be either the cell id or a gensym
indentedOutputln("<Interlink id=\""+id+"\">"); indentedOutputln("<Interlink id=\""+id+"\">");
increaseIndent(); increaseIndent();
indentedOutputln("<LinkType>owl:sameAs</LinkType>"); indentedOutputln("<LinkType>owl:sameAs</LinkType>");
indentedOutputln("<SourceDataSet datasource=\"\"" + " var=\"s\">"); indentedOutputln("<SourceDataSet dataSource=\"source\"" + " var=\"s\">");
increaseIndent(); increaseIndent();
indentedOutputln("<RestrictTo>"); indentedOutputln("<RestrictTo>");
increaseIndent();
indentedOutput(listBGP1.get(listBGP1.size()-1)); indentedOutput(listBGP1.get(listBGP1.size()-1));
decreaseIndent();
indentedOutputln("</RestrictTo>"); indentedOutputln("</RestrictTo>");
decreaseIndent(); decreaseIndent();
indentedOutputln("</SourceDataSet>"); indentedOutputln("</SourceDataSet>");
indentedOutputln("<TargetDataSet datasource=\"\"" + " var=\"x\">"); indentedOutputln("<TargetDataSet dataSource=\"target\"" + " var=\"x\">");
increaseIndent(); increaseIndent();
indentedOutputln("<RestrictTo>"); indentedOutputln("<RestrictTo>");
increaseIndent();
indentedOutput(listBGP2.get(listBGP2.size()-1)); indentedOutput(listBGP2.get(listBGP2.size()-1));
decreaseIndent();
indentedOutputln("</RestrictTo>"); indentedOutputln("</RestrictTo>");
decreaseIndent(); decreaseIndent();
indentedOutputln("</TargetDataSet>"+NL); indentedOutputln("</TargetDataSet>");
// This should certainly be specified in the EDOAL
indentedOutputln("<LinkageRule>"); indentedOutputln("<LinkageRule>");
increaseIndent(); increaseIndent();
indentedOutputln("<Compare metric=\"levenshtein\" threshold=\".5\">");
increaseIndent();
indentedOutputln("<TransformInput function=\"stripUriPrefix\">");
increaseIndent();
indentedOutputln("<Input path=\"?s\" />");
decreaseIndent();
indentedOutputln("</TransformInput>");
indentedOutputln("<TransformInput function=\"stripUriPrefix\">");
increaseIndent();
indentedOutputln("<Input path=\"?x\" />");
decreaseIndent();
indentedOutputln("</TransformInput>");
decreaseIndent();
indentedOutputln("</Compare>");
decreaseIndent(); decreaseIndent();
indentedOutputln("</LinkageRule>"); indentedOutputln("</LinkageRule>");
indentedOutputln("<Filter />"); indentedOutputln("<Filter"+threshold+limit+" />");
indentedOutputln("<Outputs>"); indentedOutputln("<Outputs>");
increaseIndent(); increaseIndent();
indentedOutputln("<Output type=\"file\">"); indentedOutputln("<Output type=\"file\">");
......
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