From f7f2dc0352a12beb45f427da749556958beac96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Sat, 23 Feb 2008 11:16:09 +0000 Subject: [PATCH] - introduced Annotation class for defining namespaces and annotation tags --- .../exmo/align/impl/Annotations.java | 33 +++++++++++++++++++ .../inrialpes/exmo/align/impl/BasicCell.java | 2 +- .../inrialpes/exmo/align/impl/Ontology.java | 3 +- .../exmo/align/impl/URIAlignment.java | 6 ++-- .../exmo/align/impl/eval/PRecEvaluator.java | 3 +- .../renderer/COWLMappingRendererVisitor.java | 4 +-- .../impl/renderer/HTMLRendererVisitor.java | 4 +-- .../impl/renderer/RDFRendererVisitor.java | 9 +++-- .../impl/renderer/XSLTRendererVisitor.java | 17 ++-------- .../exmo/align/parser/AlignmentParser.java | 4 +-- .../exmo/align/service/WSAServProfile.java | 4 +-- .../inrialpes/exmo/align/util/GroupAlign.java | 4 +-- .../inrialpes/exmo/align/util/Procalign.java | 4 +-- 13 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 src/fr/inrialpes/exmo/align/impl/Annotations.java diff --git a/src/fr/inrialpes/exmo/align/impl/Annotations.java b/src/fr/inrialpes/exmo/align/impl/Annotations.java new file mode 100644 index 00000000..08f33b04 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/Annotations.java @@ -0,0 +1,33 @@ +/* + * $Id$ + * + * Copyright (C) INRIA Rhône-Alpes, 2008 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package fr.inrialpes.exmo.align.impl; + +public class Annotations { + + public static String ALIGNNS = "http://knowledgeweb.semanticweb.org/heterogeneity/alignment#"; + public static String METHOD = "method"; + public static String TIME = "time"; + public static String ID = "id"; + + /* Set to true for rejecting the use of deprecated (non deterministic) primitives */ + protected static boolean STRICT_IMPLEMENTATION = false; + +} diff --git a/src/fr/inrialpes/exmo/align/impl/BasicCell.java b/src/fr/inrialpes/exmo/align/impl/BasicCell.java index 4ee69ad3..5e988621 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicCell.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicCell.java @@ -144,7 +144,7 @@ public class BasicCell implements Cell, Comparable { result.setExtension( ((String[])ext)[0], ((String[])ext)[1], ((String[])ext)[2] ); } } - result.getExtensions().unsetParameter( BasicAlignment.ALIGNNS+BasicAlignment.ID ); + result.getExtensions().unsetParameter( Annotations.ALIGNNS+Annotations.ID ); // The sae should be done for the measure return result; } diff --git a/src/fr/inrialpes/exmo/align/impl/Ontology.java b/src/fr/inrialpes/exmo/align/impl/Ontology.java index 72ad8a44..f2420716 100644 --- a/src/fr/inrialpes/exmo/align/impl/Ontology.java +++ b/src/fr/inrialpes/exmo/align/impl/Ontology.java @@ -1,8 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2007 - * Copyright (C) CNR Pisa, 2005 + * Copyright (C) INRIA Rhône-Alpes, 2007 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by diff --git a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java index 3deaba55..59085d10 100644 --- a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java @@ -129,7 +129,7 @@ public class URIAlignment extends BasicAlignment { // Deprecated: implement as the one retrieving the highest strength correspondence ( public Cell getAlignCell1(Object ob) throws AlignmentException { - if ( BasicAlignment.STRICT_IMPLEMENTATION == true ){ + if ( Annotations.STRICT_IMPLEMENTATION == true ){ throw new AlignmentException("getAlignCell1: deprecated (use getAlignCells1 instead)"); } else { if ( ob instanceof URI ){ @@ -141,7 +141,7 @@ public class URIAlignment extends BasicAlignment { } public Cell getAlignCell2(Object ob) throws AlignmentException { - if ( BasicAlignment.STRICT_IMPLEMENTATION == true ){ + if ( Annotations.STRICT_IMPLEMENTATION == true ){ throw new AlignmentException("getAlignCell2: deprecated (use getAlignCells2 instead)"); } else { if ( ob instanceof URI ){ @@ -175,7 +175,7 @@ public class URIAlignment extends BasicAlignment { for ( Object ext : ((BasicParameters)extensions).getValues() ){ align.setExtension( ((String[])ext)[0], ((String[])ext)[1], ((String[])ext)[2] ); } - align.getExtensions().unsetParameter( ALIGNNS+"id" ); + align.getExtensions().unsetParameter( Annotations.ALIGNNS+"id" ); try { align.ingest( this ); } catch (AlignmentException ex) { ex.printStackTrace(); } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java index 3f022da0..dd236a66 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java @@ -27,6 +27,7 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.BasicEvaluator; import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.Annotations; import java.util.Enumeration; import java.util.Iterator; @@ -133,7 +134,7 @@ public class PRecEvaluator extends BasicEvaluator { fmeasure = 2 * precision * recall / (precision + recall); overall = recall * (2 - (1 / precision)); result = recall / precision; - String timeExt = align2.getExtension( BasicAlignment.ALIGNNS, BasicAlignment.TIME ); + String timeExt = align2.getExtension( Annotations.ALIGNNS, Annotations.TIME ); if ( timeExt != null ) time = Long.parseLong(timeExt); //System.err.println(">>>> " + nbcorrect + " : " + nbfound + " : " + nbexpected); return (result); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java index 47376d27..a2008b23 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/COWLMappingRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2007 + * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2007-2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -84,7 +84,6 @@ public class COWLMappingRendererVisitor implements AlignmentVisitor } public void visit( Cell cell ) throws AlignmentException { this.cell = cell; - //OWLOntology onto1 = (OWLOntology)alignment.getOntology1(); writer.print(" <cowl:bridgeRule>\n"); cell.getRelation().accept( this ); writer.print(" </cowl:bridgeRule>\n"); @@ -166,7 +165,6 @@ public class COWLMappingRendererVisitor implements AlignmentVisitor } catch (InvocationTargetException e) { e.printStackTrace(); } - // } catch (OWLException e) { throw new AlignmentException("Dispatching problem ", e); }; } public void printObject( URI uri, OWLOntology onto ) throws OWLException { diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java index d74b4327..dba5a84b 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/HTMLRendererVisitor.java @@ -29,7 +29,7 @@ import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; -import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; /** @@ -93,7 +93,7 @@ public class HTMLRendererVisitor implements AlignmentVisitor if ( cell.getId() != null ) { String id = cell.getId(); // Would be useful to test for the Alignment URI - if ( id.startsWith( (String)alignment.getExtension( BasicAlignment.ALIGNNS, BasicAlignment.ID ) ) ){ + if ( id.startsWith( (String)alignment.getExtension( Annotations.ALIGNNS, Annotations.ID ) ) ){ writer.print("<td>"+id.substring( id.indexOf( '#' ) )+"</td>"); } else { writer.print("<td>"+id+"</td>"); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index a59677e3..5cfd8c4e 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -30,8 +30,7 @@ import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Relation; -// JE: this has been introduced here for the sole purpose of -// using the namespace facility of BasicAlignment +import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicAlignment; import fr.inrialpes.exmo.align.impl.BasicParameters; @@ -64,7 +63,7 @@ public class RDFRendererVisitor implements AlignmentVisitor String extensionString = ""; alignment = align; nslist = new Hashtable(); - nslist.put(BasicAlignment.ALIGNNS,"align"); + nslist.put(Annotations.ALIGNNS,"align"); nslist.put("http://www.w3.org/1999/02/22-rdf-syntax-ns#","rdf"); nslist.put("http://www.w3.org/2001/XMLSchema#","xsd"); //nslist.put("http://www.omwg.org/TR/d7/ontology/alignment","omwg"); @@ -84,7 +83,7 @@ public class RDFRendererVisitor implements AlignmentVisitor } writer.print("<?xml version='1.0' encoding='utf-8"); writer.print("' standalone='no'?>\n"); - writer.print("<rdf:RDF xmlns='"+BasicAlignment.ALIGNNS+"'"); + writer.print("<rdf:RDF xmlns='"+Annotations.ALIGNNS+"'"); for ( Enumeration e = nslist.keys() ; e.hasMoreElements(); ) { String k = (String)e.nextElement(); writer.print("\n xmlns:"+nslist.get(k)+"='"+k+"'"); @@ -99,7 +98,7 @@ public class RDFRendererVisitor implements AlignmentVisitor } writer.print(">\n"); writer.print("<Alignment"); - String idext = align.getExtension( BasicAlignment.ALIGNNS, BasicAlignment.ID ); + String idext = align.getExtension( Annotations.ALIGNNS, Annotations.ID ); if ( idext != null ) { writer.print(" rdf:about=\""+idext+"\""); } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java index 967105a2..a4955b86 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/XSLTRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2006-2007 + * Copyright (C) INRIA Rhône-Alpes, 2003-2004, 2006-2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -72,10 +72,6 @@ public class XSLTRendererVisitor implements AlignmentVisitor writer.println(" xmlns:"+namespaces.get(ns)+"=\""+ns+"\""); } writer.println(" >\n"); - // writer.println(" xmlns:owl=\"http://www.w3.org/2002/07/owl#\""); - //writer.println(" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\""); - //writer.println(" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" "); - //writer.println(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\">\n"); for ( Enumeration e = align.getElements() ; e.hasMoreElements(); ){ Cell c = (Cell)e.nextElement(); @@ -99,16 +95,7 @@ public class XSLTRendererVisitor implements AlignmentVisitor public void visit( Cell cell ) throws AlignmentException { this.cell = cell; - // This was here for avoiding to treat individuals... - //OWLOntology onto1 = (OWLOntology)alignment.getOntology1(); - //try { - // URI entity1URI = ((OWLEntity)cell.getObject1()).getURI(); - // if ( ((OWLEntity)onto1.getClass( entity1URI ) != null ) - // || ((OWLEntity)onto1.getDataProperty( entity1URI ) != null) - // || ((OWLEntity)onto1.getObjectProperty( entity1URI ) != null )) { - cell.getRelation().accept( this ); - // } - //} catch (OWLException e) { throw new AlignmentException("getURI problem", e); }; + cell.getRelation().accept( this ); } private void collectURIs ( Cell cell ) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java index 8a6fe127..6b3f7979 100644 --- a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java +++ b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java @@ -55,7 +55,7 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.Ontology; import fr.inrialpes.exmo.align.impl.URIAlignment; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.Annotations; /** * This class allows the creation of a parser for an Alignment file. @@ -312,7 +312,7 @@ public class AlignmentParser extends DefaultHandler { onto1 = new Ontology(); onto2 = new Ontology(); if ( atts.getValue("rdf:about") != null && !atts.getValue("rdf:about").equals("") ) { - alignment.setExtension( BasicAlignment.ALIGNNS, BasicAlignment.ID, atts.getValue("rdf:about") ); + alignment.setExtension( Annotations.ALIGNNS, Annotations.ID, atts.getValue("rdf:about") ); }; } else { if ( debugMode > 0 ) System.err.println("[AlignmentParser] Unknown element name : "+pName); diff --git a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java index 51897994..12ec5dd6 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java @@ -21,7 +21,7 @@ package fr.inrialpes.exmo.align.service; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.Annotations; import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.Parameters; @@ -219,7 +219,7 @@ public class WSAServProfile implements AlignmentServiceProfile { } else if ( method.equals("listalignmentsRequest") ) { msg += "<listalignmentsResponse><alignmentList>"; for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension(BasicAlignment.ALIGNNS, BasicAlignment.ID); + String id = ((Alignment)e.nextElement()).getExtension(Annotations.ALIGNNS, Annotations.ID); msg += "<alid>"+id+"</alid>"; } msg += "</alignmentList></listalignmentsResponse>"; diff --git a/src/fr/inrialpes/exmo/align/util/GroupAlign.java b/src/fr/inrialpes/exmo/align/util/GroupAlign.java index 372c326d..55c77571 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupAlign.java +++ b/src/fr/inrialpes/exmo/align/util/GroupAlign.java @@ -36,7 +36,7 @@ import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Parameters; -import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.OntologyCache; import fr.inrialpes.exmo.align.parser.AlignmentParser; @@ -304,7 +304,7 @@ public class GroupAlign { long time = System.currentTimeMillis(); result.align(init, params); // add opts long newTime = System.currentTimeMillis(); - result.setExtension( BasicAlignment.ALIGNNS, BasicAlignment.TIME, Long.toString(newTime - time) ); + result.setExtension( Annotations.ALIGNNS, Annotations.TIME, Long.toString(newTime - time) ); if (debug > 1) System.err.println(" Alignment performed"); diff --git a/src/fr/inrialpes/exmo/align/util/Procalign.java b/src/fr/inrialpes/exmo/align/util/Procalign.java index 3b425b4d..0a0fd689 100644 --- a/src/fr/inrialpes/exmo/align/util/Procalign.java +++ b/src/fr/inrialpes/exmo/align/util/Procalign.java @@ -32,7 +32,7 @@ import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Parameters; -import fr.inrialpes.exmo.align.impl.BasicAlignment; +import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.OntologyCache; @@ -247,7 +247,7 @@ public class Procalign { long time = System.currentTimeMillis(); result.align( init, params ); // add opts long newTime = System.currentTimeMillis(); - result.setExtension( BasicAlignment.ALIGNNS, BasicAlignment.TIME, Long.toString(newTime - time) ); + result.setExtension( Annotations.ALIGNNS, Annotations.TIME, Long.toString(newTime - time) ); // Thresholding if (threshold != 0) result.cut( cutMethod, threshold ); -- GitLab