Mentions légales du service

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

- Modified Cell interface so that object URIs can be found in a generic way

        -> solves a database storage bug
parent 0bf7dfd8
No related branches found
No related tags found
No related merge requests found
Showing
with 134 additions and 40 deletions
......@@ -223,7 +223,7 @@ public class OWLAPIAlignment extends ObjectAlignment {
for (Enumeration e = getElements(); e.hasMoreElements();) {
OWLAPICell c = (OWLAPICell)e.nextElement(); //[W:Deprecated]
try {
align.addAlignCell( c.getId(), c.getObject1AsURI(), c.getObject2AsURI(), c.getRelation(), c.getStrength() );
align.addAlignCell( c.getId(), c.getObject1AsURI(this), c.getObject2AsURI(this), c.getRelation(), c.getStrength() );
} catch (AlignmentException aex) {
// Sometimes URIs are null, this is ignored
}
......@@ -245,11 +245,11 @@ public class OWLAPIAlignment extends ObjectAlignment {
//System.err.println( o1 );
for (Enumeration e = al.getElements(); e.hasMoreElements();) {
Cell c = (Cell)e.nextElement();
//System.err.println( c.getObject1AsURI() );
//System.err.println( c.getObject2AsURI() );
//System.err.println( c.getObject1AsURI(this) );
//System.err.println( c.getObject2AsURI(this) );
alignment.addAlignCell( c.getId(),
getEntity( o1, c.getObject1AsURI() ),
getEntity( o2, c.getObject2AsURI() ),
getEntity( o1, c.getObject1AsURI(al) ),
getEntity( o2, c.getObject2AsURI(al) ),
c.getRelation(),
c.getStrength(),
c.getExtensions() );
......
......@@ -150,7 +150,7 @@ public class ObjectAlignment extends BasicAlignment {
for (Enumeration e = getElements(); e.hasMoreElements();) {
Cell c = (Cell)e.nextElement();
try {
align.addAlignCell( c.getId(), c.getObject1AsURI(), c.getObject2AsURI(), c.getRelation(), c.getStrength() );
align.addAlignCell( c.getId(), c.getObject1AsURI(this), c.getObject2AsURI(this), c.getRelation(), c.getStrength() );
} catch (AlignmentException aex) {
// Sometimes URIs are null, this is ignore
}
......@@ -171,8 +171,8 @@ public class ObjectAlignment extends BasicAlignment {
for (Enumeration e = al.getElements(); e.hasMoreElements();) {
Cell c = (Cell)e.nextElement();
alignment.addAlignCell( c.getId(),
o1.getEntity( c.getObject1AsURI() ),
o2.getEntity( c.getObject2AsURI() ),
o1.getEntity( c.getObject1AsURI(alignment) ),
o2.getEntity( c.getObject2AsURI(alignment) ),
c.getRelation(),
c.getStrength(),
c.getExtensions() );
......
......@@ -116,17 +116,17 @@ public class PRGraphEvaluator extends BasicEvaluator {
} else if ( ((Cell)o1).getStrength() < ((Cell)o2).getStrength() ){
return 1;
//The comparator must always tell that things are different!
} else if ( (((Cell)o1).getObject1AsURI().getFragment() == null)
|| (((Cell)o2).getObject1AsURI().getFragment() == null) ) {
} else if ( (((Cell)o1).getObject1AsURI(align1).getFragment() == null)
|| (((Cell)o2).getObject1AsURI(align2).getFragment() == null) ) {
return -1;
} else if ( ((Cell)o1).getObject1AsURI().getFragment().compareTo(((Cell)o2).getObject1AsURI().getFragment()) > 0) {
} else if ( ((Cell)o1).getObject1AsURI(align1).getFragment().compareTo(((Cell)o2).getObject1AsURI(align2).getFragment()) > 0) {
return -1;
} else if ( ((Cell)o1).getObject1AsURI().getFragment().compareTo(((Cell)o2).getObject1AsURI().getFragment()) < 0 ) {
} else if ( ((Cell)o1).getObject1AsURI(align1).getFragment().compareTo(((Cell)o2).getObject1AsURI(align2).getFragment()) < 0 ) {
return 1;
} else if ( (((Cell)o1).getObject2AsURI().getFragment() == null)
|| (((Cell)o2).getObject2AsURI().getFragment() == null) ) {
} else if ( (((Cell)o1).getObject2AsURI(align1).getFragment() == null)
|| (((Cell)o2).getObject2AsURI(align2).getFragment() == null) ) {
return -1;
} else if ( ((Cell)o1).getObject2AsURI().getFragment().compareTo(((Cell)o2).getObject2AsURI().getFragment()) > 0) {
} else if ( ((Cell)o1).getObject2AsURI(align1).getFragment().compareTo(((Cell)o2).getObject2AsURI(align2).getFragment()) > 0) {
return -1;
// We assume that they have different names
} else { return 1; }
......@@ -151,8 +151,8 @@ public class PRGraphEvaluator extends BasicEvaluator {
if( s1 != null ){ // for all cells matching our first entity
for( Iterator it1 = s1.iterator(); it1.hasNext() && c2 != null; ){
Cell c1 = (Cell)it1.next();
URI uri1 = c1.getObject2AsURI();
URI uri2 = c2.getObject2AsURI();
URI uri1 = c1.getObject2AsURI(align1);
URI uri2 = c2.getObject2AsURI(align2);
if (uri1.toString().equals(uri2.toString())) { //This cell matches a correct one
nbcorrect++;
double recall = (double)nbcorrect / (double)nbexpected;
......
......@@ -140,6 +140,31 @@ public class PRecEvaluator extends BasicEvaluator {
return (result);
}
public String HTMLString (){
String result = "";
result += " <div xmlns:map='http://www.atl.external.lmco.com/projects/ontology/ResultsOntology.n3#' typeof=\"map:output\" href=''>";
result += " <dl>";
//if ( ) {
// result += " <dt>algorithm</dt><dd property=\"map:algorithm\">"+align1.get+"</dd>";
//}
try {
result += " <dt>input1</dt><dd rel=\"map:input1\" href=\""+align1.getOntology1URI()+"\">"+align1.getOntology1URI()+"</dd>";
result += " <dt>input2</dt><dd rel=\"map:input2\" href=\""+align1.getOntology2URI()+"\">"+align1.getOntology2URI()+"</dd>";
} catch (AlignmentException e) { e.printStackTrace(); };
// Other missing items (easy to get)
// result += " <map:falseNegative>");
// result += " <map:falsePositive>");
result += " <dt>precision</dt><dd property=\"map:precision\">"+precision+"</dd>\n";
result += " <dt>recall</dt><dd property=\"map:recall\">"+recall+"</dd>\n";
result += " <dt>fallout</dt><dd property=\"map:fallout\">"+fallout+"</dd>\n";
result += " <dt>F-measure</dt><dd property=\"map:fMeasure\">"+fmeasure+"</dd>\n";
result += " <dt>O-measure</dt><dd property=\"map:oMeasure\">"+overall+"</dd>\n";
if ( time != 0 ) result += " <dt>time</dt><dd property=\"map:time\">"+time+"</dd>\n";
result += " <dt>result</dt><dd property=\"map:result\">"+result+"</dd>\n";
result += " </dl>\n </div>\n";
return result;
}
/**
* This now output the results in Lockheed format.
*/
......
......@@ -130,14 +130,14 @@ public class HTMLRendererVisitor implements AlignmentVisitor
public void visit( Cell cell ) throws AlignmentException {
this.cell = cell;
URI u1, u2;
if ( cell instanceof ObjectCell ) {
u1 = ((LoadedOntology)((BasicAlignment)alignment).getOntologyObject1()).getEntityURI( cell.getObject1() );
u2 = ((LoadedOntology)((BasicAlignment)alignment).getOntologyObject2()).getEntityURI( cell.getObject2() );
} else {
System.err.println( cell );
u1 = cell.getObject1AsURI();
u2 = cell.getObject2AsURI();
}
// JE: I think that now these two clauses should be unified (3.4)
//if ( cell instanceof ObjectCell ) {
// u1 = ((LoadedOntology)((BasicAlignment)alignment).getOntologyObject1()).getEntityURI( cell.getObject1() );
// u2 = ((LoadedOntology)((BasicAlignment)alignment).getOntologyObject2()).getEntityURI( cell.getObject2() );
//} else {
u1 = cell.getObject1AsURI( alignment );
u2 = cell.getObject2AsURI( alignment );
//}
writer.print(" <tr typeof=\"align:Cell\">");
writer.print("<td rel=\"align:entity1\" href=\""+u1+"\">"+u1+"</td><td property=\"align:relation\">");
cell.getRelation().accept( this );
......
......@@ -76,7 +76,7 @@ public class SKOSRendererVisitor implements AlignmentVisitor {
if ( onto2 != null ) {
return onto2.getEntityURI( cell.getObject2() );
} else {
return cell.getObject2AsURI();
return cell.getObject2AsURI( alignment );
}
}
......@@ -85,7 +85,7 @@ public class SKOSRendererVisitor implements AlignmentVisitor {
if ( onto1 != null ) {
writer.print(" <skos:Concept rdf:about=\""+onto1.getEntityURI( cell.getObject1() )+"\">\n");
} else {
writer.print(" <skos:Concept rdf:about=\""+cell.getObject1AsURI()+"\">\n");
writer.print(" <skos:Concept rdf:about=\""+cell.getObject1AsURI( alignment )+"\">\n");
}
cell.getRelation().accept( this );
writer.print(" </skos:Concept>\n\n");
......
......@@ -107,12 +107,13 @@ public class XSLTRendererVisitor implements AlignmentVisitor {
private void collectURIs ( Cell cell ) throws AlignmentException {
URI entity1URI, entity2URI;
// JE: I think that now these two clauses should be unified (3.4)
if ( onto1 != null ){
entity1URI = onto1.getEntityURI( cell.getObject1() );
entity2URI = onto2.getEntityURI( cell.getObject2() );
} else {
entity1URI = cell.getObject1AsURI();
entity2URI = cell.getObject2AsURI();
entity1URI = cell.getObject1AsURI(alignment);
entity2URI = cell.getObject2AsURI(alignment);
}
if ( entity1URI != null ) {
String ns1 = entity1URI.getScheme()+":"+entity1URI.getSchemeSpecificPart()+"#";
......@@ -134,8 +135,8 @@ public class XSLTRendererVisitor implements AlignmentVisitor {
writer.println(" <xsl:template match=\""+namespacify(onto1.getEntityURI( cell.getObject1() ))+"\">");
writer.println(" <xsl:element name=\""+namespacify(onto2.getEntityURI( cell.getObject2() ))+"\">");
} else {
writer.println(" <xsl:template match=\""+namespacify(cell.getObject1AsURI())+"\">");
writer.println(" <xsl:element name=\""+namespacify(cell.getObject2AsURI())+"\">");
writer.println(" <xsl:template match=\""+namespacify(cell.getObject1AsURI(alignment))+"\">");
writer.println(" <xsl:element name=\""+namespacify(cell.getObject2AsURI(alignment))+"\">");
}
writer.println(" <xsl:apply-templates select=\"*|@*|text()\"/>");
writer.println(" </xsl:element>");
......
......@@ -450,6 +450,7 @@ public class AServProtocolManager {
} catch (Exception e) {
return new UnknownAlignment(newId(),mess,myId,mess.getSender(),"unknown/Alignment/"+id,(Parameters)null);
}
System.err.println( id +" -- "+al);
// Invert it
try { al = al.inverse(); }
catch (AlignmentException e) {
......@@ -474,6 +475,40 @@ public class AServProtocolManager {
return new AlignmentId(newId(),mess,myId,mess.getSender(),"dummy//",(Parameters)null);
}
// It is also possible to try a groupeval ~> with a zipfile containing results
// ~~> But it is more difficut to know where is the reference (non public)
// There should also be options for selecting the result display
// ~~> PRGraph (but this may be a Evaluator)
// ~~> Triangle
// ~~> Cross
public Message eval( Message mess ){
Parameters params = mess.getParameters();
// Retrieve the alignment
String id = (String)params.getParameter("id");
Alignment al = null;
try {
al = alignmentCache.getAlignment( id );
} catch (Exception e) {
return new UnknownAlignment(newId(),mess,myId,mess.getSender(),"unknown/Alignment/"+id,(Parameters)null);
}
// Retrieve the reference alignment
String rid = (String)params.getParameter("ref");
Alignment ref = null;
try {
ref = alignmentCache.getAlignment( rid );
} catch (Exception e) {
return new UnknownAlignment(newId(),mess,myId,mess.getSender(),"unknown/Alignment/"+rid,(Parameters)null);
}
// Set the comparison method
// Compare it
try { al = al.inverse(); }
catch (AlignmentException e) {
return new ErrorMsg(newId(),mess,myId,mess.getSender(),"dummy//",(Parameters)null);
}
// Return it, not easy
return new AlignmentId(newId(),mess,myId,mess.getSender(),"dummy//",(Parameters)null);
}
public boolean storedAlignment( Message mess ) {
// Retrieve the alignment
String id = (String)mess.getParameters().getParameter("id");
......
......@@ -37,6 +37,7 @@ import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import fr.inrialpes.exmo.align.impl.BasicAlignment;
import fr.inrialpes.exmo.align.impl.BasicRelation;
import fr.inrialpes.exmo.align.impl.Annotations;
import fr.inrialpes.exmo.align.impl.BasicParameters;
......@@ -439,8 +440,25 @@ public class CacheImpl {
public boolean isAlignmentStored( Alignment alignment ) {
if ( alignment.getExtension( SVCNS, STORED ) != null &&
!alignment.getExtension( SVCNS, STORED ).equals("") )
return false;
else return true;
return true;
else return false;
}
/**
* Non publicised class
*/
public void unStoreAlignment( String id ) throws Exception {
Alignment alignment = getAlignment( id );
if ( alignment != null ) {
Statement st = (Statement) conn.createStatement();
String query = "DELETE FROM extension WHERE id=''";
st.executeUpdate(query);
query = "DELETE FROM alignment WHERE id=''";
st.executeUpdate(query);
query = "DELETE FROM cell WHERE id=''";
st.executeUpdate(query);
alignment.setExtension( SVCNS, STORED, "");
}
}
public void storeAlignment( String id ) throws Exception {
......@@ -501,8 +519,8 @@ public class CacheImpl {
cellid = c.getId();
}
else cellid = "";
String uri1 = c.getObject1AsURI().toString();
String uri2 = c.getObject2AsURI().toString();
String uri1 = c.getObject1AsURI(alignment).toString();
String uri2 = c.getObject2AsURI(alignment).toString();
String strength = c.getStrength() + ""; // crazy Java
String sem;
if ( !c.getSemantics().equals("first-order") )
......@@ -528,7 +546,11 @@ public class CacheImpl {
}
}
}
} catch (Exception e) { e.printStackTrace(); };
} catch (Exception e) {
// We should cancel this... IF NOT STORED!
alignment.setExtension( SVCNS, STORED, "");
e.printStackTrace();
};
// We reset cached date
resetCacheStamp(alignment);
}
......@@ -644,7 +666,7 @@ public class CacheImpl {
Statement st2 = (Statement) conn.createStatement();
while ( rse.next() ){
String tag = rse.getString("tag");
System.err.println(" Treating tag "+tag+" of "+rse.getString("id"));
//System.err.println(" Treating tag "+tag+" of "+rse.getString("id"));
if ( !tag.equals("") ){
int pos;
String ns;
......@@ -662,7 +684,7 @@ public class CacheImpl {
ns = Annotations.ALIGNNS;
name = tag;
}
System.err.println(" >> "+ns+" : "+name);
//System.err.println(" >> "+ns+" : "+name);
st2.executeUpdate("UPDATE extension SET tag='"+name+"', uri='"+ns+"' WHERE id='"+rse.getString("id")+"' AND tag='"+tag+"'");
}
}
......
......@@ -30,6 +30,7 @@ package fr.inrialpes.exmo.align.service;
import fr.inrialpes.exmo.queryprocessor.QueryProcessor;
import fr.inrialpes.exmo.queryprocessor.Result;
import fr.inrialpes.exmo.queryprocessor.Type;
import fr.inrialpes.exmo.align.impl.BasicAlignment;
import fr.inrialpes.exmo.align.parser.AlignmentParser;
......@@ -188,8 +189,8 @@ public class QueryMediator implements QueryProcessor {
for( Enumeration e = align.getElements() ; e.hasMoreElements(); ){
Cell cell = (Cell)e.nextElement();
mainQuery = mainQuery.replaceAll(
cell.getObject1AsURI().toString(),
cell.getObject2AsURI().toString() );
cell.getObject1AsURI(align).toString(),
cell.getObject2AsURI(align).toString() );
}
return mainQuery;
}
......
......@@ -51,8 +51,18 @@ public interface Cell extends Comparable<Cell> {
public void setSemantics( String s );
public Object getObject1();
public Object getObject2();
/**
* //@deprecated use getObject1AsURI( null ) instead
*/
//@Deprecated
public URI getObject1AsURI() throws AlignmentException;
/**
* //@deprecated use getObject2AsURI( null ) instead
*/
//@Deprecated
public URI getObject2AsURI() throws AlignmentException;
public URI getObject1AsURI( Alignment al ) throws AlignmentException;
public URI getObject2AsURI( Alignment al ) throws AlignmentException;
public void setObject1( Object ob ) throws AlignmentException;
public void setObject2( Object ob ) throws AlignmentException;
public Relation getRelation();
......
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