diff --git a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java index 209b8a8cf3f661d166b240ca2dd554f33b0efb7f..1fc5b8f9eae312c9d8ee83aefa335971965260d8 100644 --- a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2003-2008 + * Copyright (C) INRIA, 2003-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 diff --git a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java index 4a91ee9c2249b5500888f9514ae7e156156de00e..87304751daba6cdf2e0d0e9df331f17f0e40b9b3 100644 --- a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java @@ -44,7 +44,6 @@ import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.onto.OntologyFactory; -import fr.inrialpes.exmo.align.onto.OntologyCache; import fr.inrialpes.exmo.align.onto.Ontology; import fr.inrialpes.exmo.align.onto.LoadedOntology; @@ -69,32 +68,20 @@ public class OWLAPIAlignment extends ObjectAlignment { public OWLAPIAlignment() {} public void init(Object onto1, Object onto2) throws AlignmentException { - init( onto1, onto2, (OntologyCache)null ); - } - - public void init(Object o1, Object o2, Object ontologies) throws AlignmentException { - OntologyCache cache = null; - if ( ontologies instanceof OntologyCache ) cache = (OntologyCache)ontologies; - else cache = (OntologyCache)null; - // JE: why should this happen now? Never? - if ( (o1 instanceof OWLOntology && o2 instanceof OWLOntology) - || (o1 instanceof Ontology && o2 instanceof Ontology) ){ - super.init( o1, o2, ontologies ); - } else if ( o1 instanceof URI && o2 instanceof URI ) { - super.init( loadOntology( (URI)o1, cache ), - loadOntology( (URI)o2, cache ) ); + if ( (onto1 instanceof OWLOntology && onto2 instanceof OWLOntology) + || (onto1 instanceof Ontology && onto2 instanceof Ontology) ){ + super.init( onto1, onto2 ); + } else if ( onto1 instanceof URI && onto2 instanceof URI ) { + super.init( loadOntology( (URI)onto1 ), + loadOntology( (URI)onto2 ) ); } else { throw new AlignmentException("arguments must be OWLOntology or URI"); }; } public void loadInit( Alignment al ) throws AlignmentException { - loadInit( al, (OntologyCache)null ); - } - - public void loadInit( Alignment al, OntologyCache ontologies ) throws AlignmentException { if ( al instanceof URIAlignment ) { - try { init = toOWLAPIAlignment( (URIAlignment)al, ontologies ); + try { init = toOWLAPIAlignment( (URIAlignment)al ); } catch (SAXException e) { e.printStackTrace(); } catch (OWLException e) { e.printStackTrace(); } } else if ( al instanceof OWLAPIAlignment ) { @@ -237,9 +224,9 @@ public class OWLAPIAlignment extends ObjectAlignment { } // Here it becomes necessary to load OWL: This is done by init(). - static public OWLAPIAlignment toOWLAPIAlignment( URIAlignment al, OntologyCache ontologies ) throws AlignmentException, SAXException, OWLException { + static public OWLAPIAlignment toOWLAPIAlignment( URIAlignment al ) throws AlignmentException, SAXException, OWLException { OWLAPIAlignment alignment = new OWLAPIAlignment(); - alignment.init( al.getFile1(), al.getFile2(), ontologies ); + alignment.init( al.getFile1(), al.getFile2() ); alignment.setType( al.getType() ); alignment.setLevel( al.getLevel() ); for ( Object ext : ((BasicParameters)al.getExtensions()).getValues() ){ @@ -247,11 +234,8 @@ public class OWLAPIAlignment extends ObjectAlignment { } OWLOntology o1 = (OWLOntology)alignment.getOntology1(); OWLOntology o2 = (OWLOntology)alignment.getOntology2(); - //System.err.println( o1 ); for (Enumeration e = al.getElements(); e.hasMoreElements();) { Cell c = (Cell)e.nextElement(); - //System.err.println( c.getObject1AsURI(this) ); - //System.err.println( c.getObject2AsURI(this) ); alignment.addAlignCell( c.getId(), getEntity( o1, c.getObject1AsURI(al) ), getEntity( o2, c.getObject2AsURI(al) ), diff --git a/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java b/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java index 3a2a75f5aa5a48578d88eaf09d7d0e8ffca65f40..d15989eba0923e8fec05e3bbff7d6a9cc62c8ab3 100644 --- a/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/ObjectAlignment.java @@ -40,7 +40,6 @@ import org.semanticweb.owl.align.Relation; import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.onto.OntologyFactory; -import fr.inrialpes.exmo.align.onto.OntologyCache; import fr.inrialpes.exmo.align.onto.Ontology; import fr.inrialpes.exmo.align.onto.LoadedOntology; @@ -61,18 +60,11 @@ public class ObjectAlignment extends BasicAlignment { public ObjectAlignment() {} public void init(Object onto1, Object onto2) throws AlignmentException { - init( onto1, onto2, (OntologyCache)null ); - } - - public void init(Object o1, Object o2, Object ontologies) throws AlignmentException { - OntologyCache cache = null; - if ( ontologies instanceof OntologyCache ) cache = (OntologyCache)ontologies; - else cache = (OntologyCache)null; - if ( (o1 instanceof LoadedOntology && o2 instanceof LoadedOntology) ){ - super.init( o1, o2, ontologies ); - } else if ( o1 instanceof URI && o2 instanceof URI ) { - super.init( loadOntology( (URI)o1, cache ), - loadOntology( (URI)o2, cache ) ); + if ( (onto1 instanceof LoadedOntology && onto2 instanceof LoadedOntology) ){ + super.init( onto1, onto2 ); + } else if ( onto1 instanceof URI && onto2 instanceof URI ) { + super.init( loadOntology( (URI)onto1 ), + loadOntology( (URI)onto2 ) ); } else { throw new AlignmentException("Arguments must be LoadedOntology or URI"); }; @@ -87,12 +79,8 @@ public class ObjectAlignment extends BasicAlignment { } public void loadInit( Alignment al ) throws AlignmentException { - loadInit( al, (OntologyCache)null ); - } - - public void loadInit( Alignment al, OntologyCache ontologies ) throws AlignmentException { if ( al instanceof URIAlignment ) { - try { init = toObjectAlignment( (URIAlignment)al, ontologies ); + try { init = toObjectAlignment( (URIAlignment)al ); } catch (SAXException e) { e.printStackTrace(); } } else if ( al instanceof ObjectAlignment ) { init = (ObjectAlignment)al; @@ -163,9 +151,9 @@ public class ObjectAlignment extends BasicAlignment { return align; } - static public ObjectAlignment toObjectAlignment( URIAlignment al, OntologyCache ontologies ) throws AlignmentException, SAXException { + static public ObjectAlignment toObjectAlignment( URIAlignment al ) throws AlignmentException, SAXException { ObjectAlignment alignment = new ObjectAlignment(); - alignment.init( al.getFile1(), al.getFile2(), ontologies ); + alignment.init( al.getFile1(), al.getFile2() ); alignment.setType( al.getType() ); alignment.setLevel( al.getLevel() ); for ( Object ext : ((BasicParameters)al.getExtensions()).getValues() ){ @@ -185,9 +173,9 @@ public class ObjectAlignment extends BasicAlignment { return alignment; } - static LoadedOntology loadOntology( URI ref, OntologyCache ontologies ) throws AlignmentException { - OntologyFactory factory = OntologyFactory.newInstance(); - return factory.loadOntology( ref, ontologies ); + static LoadedOntology loadOntology( URI ref ) throws AlignmentException { + OntologyFactory factory = OntologyFactory.getFactory(); + return factory.loadOntology( ref ); } } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java index 75e5baadba79e9356b910f08312852d80c6c4215..1fdb3e4f3f784e68e8eb585adf3734a4a54c181b 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java @@ -195,7 +195,7 @@ public class ExtPREvaluator extends BasicEvaluator { } public boolean isSuperProperty( Object prop1, Object prop2, HeavyLoadedOntology<Object> ontology ) throws AlignmentException { - return ontology.getSuperProperties( prop2 ).contains( prop1 ); + return ontology.getSuperProperties( prop2, true, true, true ).contains( prop1 ); } @@ -218,7 +218,7 @@ public class ExtPREvaluator extends BasicEvaluator { public int isSuperClass( Object class1, Object class2, HeavyLoadedOntology<Object> ontology ) throws AlignmentException { URI uri1 = ontology.getEntityURI( class1 ); Set<Object> bufferedSuperClasses = null; - Set<Object> superclasses = ontology.getAssertedSuperClasses( class1 ); + Set<Object> superclasses = ontology.getSuperClasses( class1, true, true, true ); int level = 0; while ( !superclasses.isEmpty() ){ @@ -234,7 +234,7 @@ public class ExtPREvaluator extends BasicEvaluator { } else { // [W:unchecked] due to OWL API not serving generic types //superclasses.addAll(((OWLClass)entity).getSuperClasses( ontology )); // [W:unchecked] - superclasses.addAll( ontology.getAssertedSuperClasses( entity ) ); + superclasses.addAll( ontology.getSuperClasses( entity, true, true, true ) ); } } } diff --git a/src/fr/inrialpes/exmo/align/onto/OntologyCache.java b/src/fr/inrialpes/exmo/align/onto/OntologyCache.java index 58675d5e71685edbe3a42ec1e3fb93344ae5aebd..452b0d098480eba5262a50844dcdb2391b424134 100644 --- a/src/fr/inrialpes/exmo/align/onto/OntologyCache.java +++ b/src/fr/inrialpes/exmo/align/onto/OntologyCache.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2007-2008 + * Copyright (C) INRIA, 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 @@ -27,44 +27,45 @@ import java.util.Enumeration; import java.net.URI; /** - * This caches the loaded ontologies so that it is possible to share them between alignments + * This caches the loaded ontologies so that it is possible + * to share them between alignments * as well as to unload them if necessary. * - * NOTE[3.2]: This class may be obsoleted and its code go to OntolofyFactory - * * @author Jérôme Euzenat * @version $Id$ + * + * This class should be parameterized by O subClassOf LoadedOntology */ -public class OntologyCache { +public class OntologyCache <O extends LoadedOntology> { /** The list of currently loaded ontologies as a function: * URI --> Ontology * This is the ontology URI, NOT its filename */ - Hashtable<URI,LoadedOntology> ontologies = null; - Hashtable<URI,LoadedOntology> ontologyUris = null; + Hashtable<URI,O> ontologies = null; + Hashtable<URI,O> ontologyUris = null; public OntologyCache() { - ontologies = new Hashtable<URI,LoadedOntology>(); - ontologyUris = new Hashtable<URI,LoadedOntology>(); + ontologies = new Hashtable<URI,O>(); + ontologyUris = new Hashtable<URI,O>(); } - public void recordOntology( URI uri, LoadedOntology ontology ){ + public void recordOntology( URI uri, O ontology ){ ontologies.put( uri, ontology ); ontologyUris.put( ontology.getURI(), ontology ); } - public LoadedOntology getOntology( URI uri ){ + public O getOntology( URI uri ){ return ontologies.get( uri ); } - public LoadedOntology getOntologyFromURI( URI uri ){ + public O getOntologyFromURI( URI uri ){ return ontologyUris.get( uri ); } - public void unloadOntology( URI uri, LoadedOntology ontology ){ - LoadedOntology o = ontologyUris.get(uri); + public void unloadOntology( URI uri, O ontology ){ + O o = ontologyUris.get(uri); o.unload(); ontologyUris.remove( uri ); ontologies.remove( uri ); diff --git a/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java b/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java index a2b5881eb5a2c9d957a22d868827117900ed98c4..56517ef226022fdb243781ac2d773664335c0b6f 100644 --- a/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java +++ b/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2008 + * Copyright (C) INRIA, 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 @@ -21,8 +21,7 @@ package fr.inrialpes.exmo.align.onto; import java.net.URI; -import java.util.HashMap; -import java.util.Map; +import java.util.Hashtable; import java.lang.reflect.InvocationTargetException; @@ -30,8 +29,9 @@ import org.semanticweb.owl.align.AlignmentException; public abstract class OntologyFactory { - protected static OntologyFactory instance; - + //protected static OntologyFactory instance = null; + protected static Hashtable<String,OntologyFactory> instances = null; + private static String API_NAME="fr.inrialpes.exmo.align.onto.owlapi10.OWLAPIOntologyFactory"; public static String getDefaultFactory(){ @@ -42,17 +42,23 @@ public abstract class OntologyFactory { API_NAME = className; } - public static OntologyFactory newInstance() { + public static OntologyFactory getFactory() { return newInstance(API_NAME); } - public static OntologyFactory newInstance(String apiName) { + // JE: The true question here is that instance being static, + // I assume that it is shared by all subclasses! + private static OntologyFactory newInstance( String apiName ) { + if ( instances == null ) instances = new Hashtable<String,OntologyFactory>(); + OntologyFactory of = instances.get( apiName ); + if ( of != null ) return of; try { + // This should also be a static getInstance! Class ofClass = Class.forName(apiName); Class[] cparams = {}; java.lang.reflect.Constructor ofConstructor = ofClass.getConstructor(cparams); Object[] mparams = {}; - instance = (OntologyFactory)ofConstructor.newInstance(mparams); + of = (OntologyFactory)ofConstructor.newInstance(mparams); } catch (ClassNotFoundException cnfex ) { cnfex.printStackTrace(); // better raise errors } catch (NoSuchMethodException nsmex) { @@ -64,17 +70,27 @@ public abstract class OntologyFactory { } catch (InvocationTargetException itex) { itex.printStackTrace(); } - return instance; + instances.put( apiName, of ); + return of; + } + + public static void clear() { + for ( OntologyFactory of : instances.values() ){ + of.clear(); + } } + public abstract void clearCache(); + /** * Load an ontology, cache enabled */ public abstract LoadedOntology loadOntology( URI uri ) throws AlignmentException; /** * Load an ontology, cache enabled if true, disabled otherwise + * This will disappear: cache will be dispatched in implementations */ - public LoadedOntology loadOntology( URI uri, OntologyCache ontologies ) throws AlignmentException { + public LoadedOntology loadOntology( URI uri, OntologyCache<LoadedOntology> ontologies ) throws AlignmentException { LoadedOntology onto = null; if ( ontologies != null ) { onto = ontologies.getOntologyFromURI( uri ); @@ -86,26 +102,4 @@ public abstract class OntologyFactory { if ( ontologies != null ) ontologies.recordOntology( uri, onto ); return onto; }; - - /* JE: this is a reimplementation of OntologyCache - // JE: This is not really useful since it doubles OntologyCache... - // This may be included as well... - protected static Map<URI,LoadedOntology> loadedOntos = new HashMap<URI,LoadedOntology>(); - protected static Map<URI,LoadedOntology> loadedOntosLogical = new HashMap<URI,LoadedOntology>(); - public LoadedOntology getOntologyFromCache( URI uri ) { - LoadedOntology onto; - if ( loadedOntos.containsKey( uri ) ) { - onto = loadedOntos.get( uri ); - } else { - onto = loadOntology( uri ); - loadedOntos.put( uri, onto ); - loadedOntosLogical.put( onto.getURI(), onto); - } - return onto; - } - - public static Ontology getOntologyFromURI(URI logicalURI) { - return loadedOntosLogical.get(logicalURI); - } - */ } diff --git a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java index bce9791d099cd6dac41d86a1fd2ee170c2ef3e8d..68b961344be4bfe67e465353ebda1af208c9ce9c 100644 --- a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java +++ b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java @@ -15,25 +15,29 @@ import fr.inrialpes.exmo.align.onto.OntologyFactory; public class JENAOntologyFactory extends OntologyFactory{ + // No cache management so far + public void clearCache() { + } + @Override public LoadedOntology loadOntology(URI uri) throws AlignmentException { try { - OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null ); - m.read(uri.toString()); - JENAOntology onto = new JENAOntology(); - onto.setFile(uri); - // to be checked : why several ontologies in a model ??? - // If no URI can be extracted from ontology, then we use the physical URI - try { - onto.setURI(new URI(((Ontology)m.listOntologies().next()).getURI())); - } - catch (NoSuchElementException nse) { - onto.setURI(new URI(m.getNsPrefixURI(""))); - //onto.setFile(uri); - } - //onto.setURI(new URI(m.listOntologies()getOntology(null).getURI())); - onto.setOntology(m); - return onto; + OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null ); + m.read(uri.toString()); + JENAOntology onto = new JENAOntology(); + onto.setFile(uri); + // to be checked : why several ontologies in a model ??? + // If no URI can be extracted from ontology, then we use the physical URI + try { + onto.setURI(new URI(((Ontology)m.listOntologies().next()).getURI())); + } + catch (NoSuchElementException nse) { + onto.setURI(new URI(m.getNsPrefixURI(""))); + //onto.setFile(uri); + } + //onto.setURI(new URI(m.listOntologies()getOntology(null).getURI())); + onto.setOntology(m); + return onto; } catch (Exception e) { throw new AlignmentException("Cannot load "+uri, e ); diff --git a/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java b/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java index 6ed121676511e7d2632b49cb4ceb6b164ada7be3..7da82f6436a21e659a845dfbd06f4b4e927122d0 100644 --- a/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java +++ b/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2007-2008 + * Copyright (C) INRIA, 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 @@ -22,7 +22,13 @@ * This should be turned into an HeavyLoadedOntology. * Some primitives are already avalible below * + * The point is that these primitives may concern: + * - Named entities / All entities + * - Asserted information / Deduced information + * - Inherited information... () + * In fact the OWL API does only provide asserted. * + * This is not very well implemented: the OWL API mandates to implement this as visitors... */ package fr.inrialpes.exmo.align.onto.owlapi10; @@ -51,6 +57,9 @@ import org.semanticweb.owl.model.OWLEntity; import org.semanticweb.owl.model.OWLRestriction; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLNaryBooleanDescription; +import org.semanticweb.owl.model.OWLCardinalityRestriction; +import org.semanticweb.owl.model.OWLDataAllRestriction; +import org.semanticweb.owl.model.OWLObjectAllRestriction; import org.semanticweb.owl.model.OWLException; import org.semanticweb.owl.model.helper.OWLEntityCollector; @@ -111,7 +120,6 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements Loaded } }; - protected Set<String> getAnnotations(final OWLEntity e , final String lang , final String typeAnnot ) throws OWLException { final OWLOntology o = this.onto; return new AbstractSet<String>() { @@ -261,6 +269,28 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements Loaded } } + public Set<Object> getAssertedProperties( Object cl ) { + Set<Object> prop = new HashSet<Object>(); + try { + for ( Object ent : ((OWLClass)cl).getSuperClasses( getOntology() ) ){ + // Not correct + if ( ent instanceof OWLRestriction ) prop.add( ent ); + } + } catch (OWLException ex) { + }; + return prop; + } + + + + public Set<Object> getAssertedObjectProperties( Object cl ){ + return null; + } + + public Set<Object> getAssertedDataProperties( Object cl ){ + return null; + } + // The only point is if I should return OWLProperties or names... // I guess that I will return names (ns+name) because otherwise I will need a full // Abstract ontology interface and this is not the rule... @@ -425,6 +455,93 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements Loaded return list; } + // NamedAssertedSuperClasses + public Set<Object> getAssertedSuperClasses( Object cl ){ + Set<Object> spcl = new HashSet<Object>(); + try { + for( Object rest : ((OWLClass)cl).getSuperClasses( getOntology() ) ){ + if (rest instanceof OWLClass) spcl.add( rest ); + } + } catch (OWLException ex) { + }; + return spcl; + } + // NamedSuperClasses + public Set<Object> getSuperClasses( Object cl ){ + Set<Object> spcl = new HashSet<Object>(); + try { + // traversing + Set<Object> sup = new HashSet<Object>(); + for( Object rest : ((OWLClass)cl).getSuperClasses( getOntology() ) ){ + if (rest instanceof OWLClass) { + spcl.add( rest ); + sup.add( rest ); + } + } + } catch (OWLException ex) { + }; + return spcl; + } + + /* public Set<Object> getSubClasses( Object cl ){ + // This will return n array and not a set... + return ((OWLClass)cl).getSuperClasses( getOntology() ); + }*/ + //OWLRestriction.getProperty() + //OWLNaryBooleanDescription.getOperand() + // JE: note this may be wrong if p is a property + public Set<Object> getCardinalityRestrictions( Object p ){//JFDK + Set<Object> spcl = new HashSet<Object>(); + try { + Set<Object> sup = ((OWLClass)p).getSuperClasses( getOntology() ); + for( Object rest : sup ){ + // This should be filtered + if (rest instanceof OWLCardinalityRestriction) spcl.add( rest ); + } + } catch (OWLException ex) { + }; + return spcl; + } + + public void getProperties( OWLDescription desc, Set<Object> list) throws OWLException { + if ( desc instanceof OWLRestriction ){ + //getProperties( (OWLRestriction)desc, list ); + list.add( ((OWLRestriction)desc).getProperty() ); + } else if ( desc instanceof OWLClass ) { + getProperties( (OWLClass)desc, list ); + } else if ( desc instanceof OWLNaryBooleanDescription ) { + for ( Object d : ((OWLNaryBooleanDescription)desc).getOperands() ){ + getProperties( (OWLDescription)d, list ); + } + //getProperties( (OWLNaryBooleanDescription)desc, list ); + } + } + public void getProperties( OWLRestriction rest, Set<Object> list) throws OWLException { + list.add( (Object)rest.getProperty() ); + } + public void getProperties( OWLNaryBooleanDescription d, Set<Object> list) throws OWLException { + for ( Iterator it = d.getOperands().iterator(); it.hasNext() ;){ + getProperties( (OWLDescription)it.next(), list ); + } + } + public void getProperties( OWLClass cl, Set<Object> list) throws OWLException { + for ( Object desc : cl.getSuperClasses( getOntology() ) ){ + getProperties( (OWLDescription)desc, list ); + } + // JE: I suspect that this can be a cause for looping!! + for ( Object desc : cl.getEquivalentClasses( getOntology() ) ){ + getProperties( (OWLDescription)desc, list ); + } + } + + private Set<Object> getProperties( OWLClass cl ) { + Set resultSet = new HashSet(); + try { getProperties( cl, resultSet ); } + catch (OWLException ex) {}; + return resultSet; + } + + public void unload() { try { ((OWLOntology)onto).getOWLConnection().notifyOntologyDeleted( ((OWLOntology)onto) ); diff --git a/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntologyFactory.java b/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntologyFactory.java index 766a139476d059d319fe71b2b11ea3e7a4f01543..7e00456c1d8fb4456cfb2207d8474c2fc95830eb 100644 --- a/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntologyFactory.java +++ b/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2008 + * Copyright (C) INRIA, 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 @@ -43,28 +43,29 @@ import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.util.OWLConnection; import org.semanticweb.owl.util.OWLManager; -/* - * JE: everything should be asked to the Ontoogy, not to the factory... - * So I suppress many initial methods - */ public class OWLAPIOntologyFactory extends OntologyFactory { - private URI formalismUri = null; - private String formalismId = "OWL1.0"; + private static URI formalismUri = null; + private static String formalismId = "OWL1.0"; + private static OntologyCache<OWLAPIOntology> cache = null; public OWLAPIOntologyFactory() { + cache = new OntologyCache<OWLAPIOntology>(); try { formalismUri = new URI("http://www.w3.org/2002/07/owl#"); } catch (URISyntaxException ex) { ex.printStackTrace(); } // should not happen }; - public static OntologyFactory getInstance() { - if (instance == null || !(instance instanceof OWLAPIOntologyFactory)) - instance = new OWLAPIOntologyFactory(); - return instance; + public void clearCache() { + cache.clear(); } - public LoadedOntology loadOntology( URI uri ) throws AlignmentException { + public OWLAPIOntology loadOntology( URI uri ) throws AlignmentException { + OWLAPIOntology onto = null; + onto = cache.getOntologyFromURI( uri ); + if ( onto != null ) return onto; + onto = cache.getOntology( uri ); + if ( onto != null ) return onto; OWLConnection connection = null; Map<Object,Object> parameters = new HashMap<Object, Object>(); parameters.put(OWLManager.OWL_CONNECTION, @@ -75,7 +76,7 @@ public class OWLAPIOntologyFactory extends OntologyFactory { Logger.getLogger("org.semanticweb.owl").setLevel(Level.ERROR); OWLOntology ontology = connection.loadOntologyPhysical(uri); Logger.getLogger("org.semanticweb.owl").setLevel(lev); - OWLAPIOntology onto = new OWLAPIOntology(); + onto = new OWLAPIOntology(); // It may be possible to fill this as final in OWLAPIOntology... onto.setFormalism( formalismId ); onto.setFormURI( formalismUri ); @@ -87,96 +88,10 @@ public class OWLAPIOntologyFactory extends OntologyFactory { // Better put in the AlignmentException of loaded e.printStackTrace(); } + cache.recordOntology( uri, onto ); return onto; } catch (OWLException e) { throw new AlignmentException("Cannot load "+uri, e ); } } - - /* Can be used for loading the ontology if it is not available - // JE: Onto: check that the structure is properly filled (see build...) - public Ontology loadOntology( URI ref, OntologyCache ontologies ) throws SAXException, AlignmentException { - Ontology onto = null; - if ( (ontologies != null) && ( ontologies.getOntology( ref ) != null ) ) { - } else if ( onto != null ) { - } else { - OWLOntology parsedOnt = null; - try { - OWLRDFParser parser = new OWLRDFParser(); - OWLRDFErrorHandler handler = new OWLRDFErrorHandler(){ - public void owlFullConstruct( int code, String message ) - throws SAXException { - } - public void owlFullConstruct(int code, String message, Object o) - throws SAXException { - } - public void error( String message ) throws SAXException { - throw new SAXException( message.toString() ); - } - public void warning( String message ) throws SAXException { - System.err.println("WARNING: " + message); - } - }; - Level lev = Logger.getLogger("org.semanticweb.owl").getLevel(); - Logger.getLogger("org.semanticweb.owl").setLevel(Level.ERROR); - parser.setOWLRDFErrorHandler( handler ); - parser.setConnection( OWLManager.getOWLConnection() ); - parsedOnt = parser.parseOntology( ref ); - Logger.getLogger("org.semanticweb.owl").setLevel(lev); - } catch (OWLException ex) { - throw new AlignmentException( "Cannot load ontology "+ref, ex ); - } - // THIS SHOULD NOW BE DONE WHEN CREATING THE ONTOLOGY - //setOntology( parsedOnt ); - //if ( ontologies != null ) ontologies.recordOntology( ref, this ); - //onto = parsedOnt; - } - return onto; - } - */ - // JE: Onto: I am not sure of the meaning of this "get" - /* - private Ontology getOntology(OWLOntology ont) { - // JE: Onto - //OntologyAdapter<OWLOntology> oModel = new OWLAPIOntology(); - Ontology oModel = new OWLAPIOntology(); - oModel.ontology=ont; - try { - oModel.uri=ont.getLogicalURI();//getURI(); - } catch (OWLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - oModel.classes = getEntities(oModel,OWLClass.class); - oModel.properties = getEntities(oModel,OWLProperty.class); - //oModel.individuals = getEntities(oModel,OWLIndividual.class); - oModel.entities = new HashSet<Entity>(oModel.properties); - oModel.entities.addAll(oModel.classes); - //oModel.entities.addAll(oModel.individuals); - - //oModel.classes = getEntities(oModel,OWLEntity.class); - return oModel; - } - */ - - /* - private class OWLAPIEntity extends EntityAdapter<OWLEntity> { - //private boolean toLoad=true; - - private OWLAPIEntity() { super(false); } - private OWLAPIEntity(OWLEntity e, Ontology o, URI u ) { - super( e, o, u, false); - } - - public Set<String> getAnnotations(String lang, TYPE type) { - if (this.annotations==null) { - init(); - addAnnotations(this); - //toLoad=false; - } - return super.getAnnotations(lang, type); - } - } - */ - } diff --git a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java index a753732f3bc20c851476e79fcbf29a159adf9b6d..23860fe93794ca24382df6096b0bc7de4ed5a91e 100644 --- a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java +++ b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java @@ -195,7 +195,7 @@ public class AlignmentParser extends DefaultHandler { * If the current process has links (import or include) to others documents then they are * parsed. * @param uri URI of the document to parse - * @param loaded should be replaced by OntologyCache (by useless) + * @param loaded (cached ontologies) * @deprecated use parse( URI ) instead */ @Deprecated diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 6b43b111e7a3dfa3568bb1cfecd41688c47e8fb0..985bbee9b56096ed21163ebd23cd51b778b7198d 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -28,7 +28,6 @@ import fr.inrialpes.exmo.align.impl.BasicAlignment; import fr.inrialpes.exmo.align.impl.URIAlignment; import fr.inrialpes.exmo.align.impl.ObjectAlignment; import fr.inrialpes.exmo.align.onto.OntologyFactory; -import fr.inrialpes.exmo.align.onto.OntologyCache; import fr.inrialpes.exmo.align.onto.Ontology; import fr.inrialpes.exmo.align.onto.LoadedOntology; @@ -86,7 +85,6 @@ public class AServProtocolManager { Set<String> services = null; Set<String> evaluators = null; - OntologyCache loadedOntologies = null; Hashtable<String,Directory> directories = null; // This should be stored somewhere @@ -111,7 +109,6 @@ public class AServProtocolManager { methods.remove("fr.inrialpes.exmo.align.impl.DistanceAlignment"); // this one is generic services = implementations( "fr.inrialpes.exmo.align.service.AlignmentServiceProfile" ); evaluators = implementations( "org.semanticweb.owl.align.Evaluator" ); - loadedOntologies = new OntologyCache(); } public void close() { @@ -360,7 +357,7 @@ public class AServProtocolManager { renderer.init( params ); al.render( renderer ); } catch ( AlignmentException aex ) { - al = ObjectAlignment.toObjectAlignment( (URIAlignment)al, (OntologyCache)null ); + al = ObjectAlignment.toObjectAlignment( (URIAlignment)al ); al.render( renderer ); } writer.flush(); @@ -632,8 +629,8 @@ public class AServProtocolManager { public LoadedOntology reachable( URI uri ){ try { - OntologyFactory factory = OntologyFactory.newInstance(); - return factory.loadOntology( uri, loadedOntologies ); + OntologyFactory factory = OntologyFactory.getFactory(); + return factory.loadOntology( uri ); } catch (Exception e) { return null; } } @@ -835,7 +832,7 @@ public class AServProtocolManager { java.lang.reflect.Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); AlignmentProcess aresult = (AlignmentProcess)alignmentConstructor.newInstance(mparams); try { - aresult.init( uri1, uri2, loadedOntologies ); + aresult.init( uri1, uri2 ); long time = System.currentTimeMillis(); aresult.align( init, params ); // add opts long newTime = System.currentTimeMillis(); @@ -861,7 +858,6 @@ public class AServProtocolManager { } catch (Exception e) { result = new RunTimeError(newId(),mess,myId,mess.getSender(),"Unexpected exception (wrong class name?)",(Parameters)null); } - loadedOntologies.clear(); // not always necessary result = new AlignmentId(newId(),mess,myId,mess.getSender(),id,(Parameters)null); } } diff --git a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java index 6f096eafcb8a348f69813f5a16b937decfec0898..3da3f03e188cf0a1fe469b85bb0e8ade420a36c9 100644 --- a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java @@ -37,7 +37,6 @@ import fr.inrialpes.exmo.align.impl.ObjectAlignment; import fr.inrialpes.exmo.align.impl.URIAlignment; import fr.inrialpes.exmo.align.impl.eval.ExtPREvaluator; import fr.inrialpes.exmo.align.parser.AlignmentParser; -import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.File; import java.io.PrintStream; @@ -99,7 +98,6 @@ public class ExtGroupEval { Vector<String> listAlgo = null; int debug = 0; String color = null; - OntologyCache loaded = null; public static void main(String[] args) { try { new ExtGroupEval().run( args ); } @@ -109,7 +107,6 @@ public class ExtGroupEval { public void run(String[] args) throws Exception { String listFile = ""; LongOpt[] longopts = new LongOpt[8]; - loaded = new OntologyCache(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); @@ -220,7 +217,7 @@ public class ExtGroupEval { result.add( i, evaluator ); } // Unload the ontologies. - loaded.clear(); + //loaded.clear(); if ( ok == true ) return result; else return null; @@ -240,11 +237,11 @@ public class ExtGroupEval { Alignment align2 = aparser.parse( alignName2 ); if ( debug > 1 ) System.err.println(" Alignment structure2 parsed"); // Create evaluator object - eval = new ExtPREvaluator(ObjectAlignment.toObjectAlignment( (URIAlignment)align1, loaded ), - ObjectAlignment.toObjectAlignment( (URIAlignment)align2, loaded ) ); + eval = new ExtPREvaluator(ObjectAlignment.toObjectAlignment( (URIAlignment)align1 ), + ObjectAlignment.toObjectAlignment( (URIAlignment)align2 ) ); // Compare params.setParameter( "debug", new Integer( nextdebug ) ); - eval.eval( params, loaded ) ; + eval.eval( params ) ; } catch (Exception ex) { if ( debug > 1 ) { ex.printStackTrace(); diff --git a/src/fr/inrialpes/exmo/align/util/GenPlot.java b/src/fr/inrialpes/exmo/align/util/GenPlot.java index e275bc70cb7aa0785e7ebc18243f3f8a99818d91..952320faf2759d3f168e63178dd58856f118ee8c 100644 --- a/src/fr/inrialpes/exmo/align/util/GenPlot.java +++ b/src/fr/inrialpes/exmo/align/util/GenPlot.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA Rhône-Alpes + * Copyright (C) 2003-2008, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -31,7 +31,7 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.eval.PRGraphEvaluator; -import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyFactory; import java.io.File; import java.io.PrintStream; @@ -97,8 +97,6 @@ public class GenPlot { String outFile = null; String type = "tsv"; int debug = 0; - //Hashtable loaded = null; - OntologyCache loaded = null; PrintWriter output = null; public static void main(String[] args) { @@ -108,8 +106,6 @@ public class GenPlot { public void run(String[] args) throws Exception { LongOpt[] longopts = new LongOpt[8]; - //loaded = new Hashtable(); - loaded = new OntologyCache(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); @@ -241,7 +237,7 @@ public class GenPlot { } } // Unload the ontologies. - loaded.clear(); + OntologyFactory.clear(); } public PRGraphEvaluator eval( String alignName1, String alignName2 ) { @@ -261,10 +257,10 @@ public class GenPlot { eval = new PRGraphEvaluator( align1, align2 ); // Compare params.setParameter( "debug", new Integer( nextdebug ) ); - eval.eval( params, loaded ) ; + eval.eval( params ) ; // Unload the ontologies. - loaded.clear(); + //loaded.clear(); } catch (Exception ex) { if ( debug > 1 ) { ex.printStackTrace(); diff --git a/src/fr/inrialpes/exmo/align/util/GenTriangle.java b/src/fr/inrialpes/exmo/align/util/GenTriangle.java index b5ac61b2fa3ea3a00e7ca83fceff7b1eff82d64f..d5d0ba20319cd3bd4671fa09d57e0f43e44085d8 100644 --- a/src/fr/inrialpes/exmo/align/util/GenTriangle.java +++ b/src/fr/inrialpes/exmo/align/util/GenTriangle.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA Rhône-Alpes + * Copyright (C) 2003-2008, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; -import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyFactory; import java.io.File; import java.io.PrintStream; @@ -97,8 +97,6 @@ public class GenTriangle { Vector<String> listAlgo = null; int debug = 0; String color = null; - //Hashtable loaded = null; - OntologyCache loaded = null; String ontoDir = null; public static void main(String[] args) { @@ -109,8 +107,6 @@ public class GenTriangle { public void run(String[] args) throws Exception { String listFile = ""; LongOpt[] longopts = new LongOpt[10]; - //loaded = new Hashtable(); - loaded = new OntologyCache(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); @@ -240,7 +236,7 @@ public class GenTriangle { result.add( i, evaluator ); } // Unload the ontologies. - loaded.clear(); + OntologyFactory.clear(); if ( ok == true ) return result; else return (Vector)null; @@ -263,7 +259,7 @@ public class GenTriangle { eval = new PRecEvaluator( align1, align2 ); // Compare params.setParameter( "debug", new Integer( nextdebug ) ); - eval.eval( params, loaded ) ; + eval.eval( params ) ; } catch (Exception ex) { System.err.println(ex); } return eval; } diff --git a/src/fr/inrialpes/exmo/align/util/GroupAlign.java b/src/fr/inrialpes/exmo/align/util/GroupAlign.java index c9e699d4ff5c47e1236239e2258ba0fca3eea12c..e47f76c207ae9cf505ddc2348bea913c83008bc3 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupAlign.java +++ b/src/fr/inrialpes/exmo/align/util/GroupAlign.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA Rhône-Alpes + * Copyright (C) 2003-2008, INRIA * Copyright (C) 2004, Université de Montréal * * Modifications to the initial code base are copyright of their @@ -39,7 +39,7 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.parser.AlignmentParser; -import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyFactory; import java.io.File; import java.io.FileOutputStream; @@ -95,7 +95,6 @@ public class GroupAlign { String target = "onto.rdf"; URI uri1 = null; String initName = null; - OntologyCache loadedOntologies = null; int debug = 0; String alignmentClassName = "fr.inrialpes.exmo.align.impl.method.StringDistAlignment"; String rendererClass = "fr.inrialpes.exmo.align.impl.renderer.RDFRendererVisitor"; @@ -109,7 +108,6 @@ public class GroupAlign { public void run(String[] args) throws Exception { LongOpt[] longopts = new LongOpt[13]; - loadedOntologies = new OntologyCache(); params = new BasicParameters(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); @@ -239,7 +237,7 @@ public class GroupAlign { if ( debug > 0 ) System.err.println("Directory: "+subdir[i]); align( subdir[i] ); // Unload the ontologies - loadedOntologies.clear(); + OntologyFactory.clear(); } catch (Exception e) { if ( debug > 1 ) e.printStackTrace(); } } @@ -278,7 +276,6 @@ public class GroupAlign { try { if (initName != null) { AlignmentParser aparser = new AlignmentParser(debug-1); - //init = aparser.parse( initName, loadedOntologies); init = aparser.parse( initName ); uri1 = init.getFile1(); uri2 = init.getFile2(); diff --git a/src/fr/inrialpes/exmo/align/util/GroupEval.java b/src/fr/inrialpes/exmo/align/util/GroupEval.java index 266420bf6edc076ef480295cc061042519f0d4e8..389b11b6beed06c00ff8da559bc05d8ed2f70569 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/GroupEval.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA Rhône-Alpes + * Copyright (C) 2003-2008, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; -import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyFactory; import java.io.File; import java.io.PrintStream; @@ -97,8 +97,6 @@ public class GroupEval { Vector<String> listAlgo = null; int debug = 0; String color = null; - //Hashtable loaded = null; - OntologyCache loaded = null; String ontoDir = null; public static void main(String[] args) { @@ -109,8 +107,6 @@ public class GroupEval { public void run(String[] args) throws Exception { String listFile = ""; LongOpt[] longopts = new LongOpt[10]; - //loaded = new Hashtable(); - loaded = new OntologyCache(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); @@ -241,7 +237,7 @@ public class GroupEval { result.add( i, evaluator ); } // Unload the ontologies. - loaded.clear(); + OntologyFactory.clear(); if ( ok == true ) return result; else return null; @@ -264,7 +260,7 @@ public class GroupEval { eval = new PRecEvaluator( align1, align2 ); // Compare params.setParameter( "debug", new Integer( nextdebug ) ); - eval.eval( params, loaded ) ; + eval.eval( params ) ; } catch (Exception ex) { if ( debug > 1 ) { ex.printStackTrace(); diff --git a/src/fr/inrialpes/exmo/align/util/GroupOutput.java b/src/fr/inrialpes/exmo/align/util/GroupOutput.java index 57c700516d738e618bb18aaa066290236a729359..dd26188bf58a6f5f1a2d5bd76104d27f6da244ba 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/util/GroupOutput.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA Rhône-Alpes + * Copyright (C) 2003-2008, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -34,7 +34,7 @@ import org.semanticweb.owl.align.Evaluator; import fr.inrialpes.exmo.align.impl.BasicParameters; import fr.inrialpes.exmo.align.impl.eval.PRecEvaluator; -import fr.inrialpes.exmo.align.onto.OntologyCache; +import fr.inrialpes.exmo.align.onto.OntologyFactory; import java.io.File; import java.io.FileOutputStream; @@ -115,8 +115,6 @@ public class GroupOutput { String type = "tex"; String color = null; int debug = 0; - //Hashtable loaded = null; - OntologyCache loaded = null; PrintWriter output = null; public static void main(String[] args) { @@ -126,8 +124,6 @@ public class GroupOutput { public void run(String[] args) throws Exception { LongOpt[] longopts = new LongOpt[8]; - //loaded = new Hashtable(); - loaded = new OntologyCache(); longopts[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'); longopts[1] = new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'); @@ -251,7 +247,7 @@ public class GroupOutput { } catch (AlignmentException aex ) { aex.printStackTrace(); } } // Unload the ontologies. - loaded.clear(); + OntologyFactory.clear(); return (double)result/(double)tests.length; } @@ -277,7 +273,7 @@ public class GroupOutput { eval = new PRecEvaluator( align1, align2 ); // Compare params.setParameter( "debug", new Integer( nextdebug ) ); - eval.eval( params, loaded ) ; + eval.eval( params ) ; return eval; } diff --git a/src/fr/inrialpes/exmo/align/util/Procalign.java b/src/fr/inrialpes/exmo/align/util/Procalign.java index 9df7b23680b8020b34cd8375be7856df43ef7761..134ed629a7d24c3b1d36806e895567ad276513e6 100644 --- a/src/fr/inrialpes/exmo/align/util/Procalign.java +++ b/src/fr/inrialpes/exmo/align/util/Procalign.java @@ -34,7 +34,6 @@ import org.semanticweb.owl.align.Parameters; import fr.inrialpes.exmo.align.impl.Annotations; import fr.inrialpes.exmo.align.impl.BasicParameters; -import fr.inrialpes.exmo.align.onto.OntologyCache; import java.io.OutputStream; import java.io.FileOutputStream; @@ -94,8 +93,6 @@ $Id$ public class Procalign { - OntologyCache loadedOntologies = null; - public static void main(String[] args) { try { new Procalign().run( args ); } catch ( Exception ex ) { ex.printStackTrace(); }; @@ -201,8 +198,6 @@ public class Procalign { debug = Integer.parseInt((String)params.getParameter("debug")); } - loadedOntologies = new OntologyCache(); - try { BasicConfigurator.configure(); @@ -234,7 +229,7 @@ public class Procalign { Class[] cparams = {}; java.lang.reflect.Constructor alignmentConstructor = alignmentClass.getConstructor(cparams); result = (AlignmentProcess)alignmentConstructor.newInstance(mparams); - result.init( uri1, uri2, loadedOntologies ); + result.init( uri1, uri2 ); } catch (Exception ex) { System.err.println("Cannot create alignment "+alignmentClassName+"\n" +ex.getMessage()); diff --git a/src/org/semanticweb/owl/align/Alignment.java b/src/org/semanticweb/owl/align/Alignment.java index c4ed3fc1a117de6533e2bdbd2117562101ad4b4b..3d0f788962d47d3643ac7c8d5fa93ffc3bbe40dd 100644 --- a/src/org/semanticweb/owl/align/Alignment.java +++ b/src/org/semanticweb/owl/align/Alignment.java @@ -43,10 +43,6 @@ public interface Alignment extends Cloneable, Iterable<Cell> { public void init( Object onto1, Object onto2 ) throws AlignmentException; - /** Initialize the alignement before using it, with some ontology caching trick **/ - - public void init( Object onto1, Object onto2, Object cache ) throws AlignmentException; - /** Alignment methods **/ public void accept( AlignmentVisitor visitor ) throws AlignmentException; diff --git a/src/org/semanticweb/owl/align/Evaluator.java b/src/org/semanticweb/owl/align/Evaluator.java index 8c7a0276b7a757efcb11f97202205caac20ef079..3c356e942cc2eae6ffac49b3eb4a516379e2de30 100644 --- a/src/org/semanticweb/owl/align/Evaluator.java +++ b/src/org/semanticweb/owl/align/Evaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2004, 2007 + * Copyright (C) INRIA, 2004, 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 @@ -30,8 +30,7 @@ import java.io.PrintWriter; */ -public interface Evaluator -{ +public interface Evaluator { /** Creation **/ //public Evaluator( OWLOntology onto1, OWLOntology onto2 );