diff --git a/html/relnotes.html b/html/relnotes.html index b7bbe9ddc0c3ecae170c91b0911fa47cc16721ff..df285fe7838d441357c54527b43e3c83456f7d8f 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -65,6 +65,7 @@ The development of 4 versions continues. <li>Added <tt>WeightedPRecEvaluator</tt> weighting confidences (eval)</li> <li>Added <tt>toURIAlignment</tt> and <tt>toEDOALAlignment</tt> for <tt>EDOALAlignment</tt> (edoal)</li> <li>Added matching test generator facility (gen)</li> +<li>Added autoselecting <tt>BasicOntology.load()</tt> (ontowrap)</li> <li>Suppressed <tt>EDOALRelation</tt>: EDOAL uses <tt>BasicRelation</tt> (edoal)</li> <li>EDOAL default printout now uses pretty relations, i.e., <, >, =, % (edoal)</li> <li>Changed order of display to precision/F-measure/recall (util)</li> diff --git a/src/fr/inrialpes/exmo/ontowrap/BasicOntology.java b/src/fr/inrialpes/exmo/ontowrap/BasicOntology.java index 027f30d8993aaf36478e46942058d9792f8f22cc..0a062f558094ef7c49a25631c79ba06cff9e8c63 100644 --- a/src/fr/inrialpes/exmo/ontowrap/BasicOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/BasicOntology.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2007-2008, 2010 + * Copyright (C) INRIA, 2007-2008, 2010-2011 * * 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 @@ -60,4 +60,25 @@ public class BasicOntology<O> implements Ontology<O> { } return result; } + + public LoadedOntology load() throws OntowrapException { + OntowrapException ex = null; + // Try to use the default factory + try { + return OntologyFactory.getFactory().loadOntology( file ); + } catch ( OntowrapException owex ) { + ex = new OntowrapException( "Cannot load ontology "+file, owex ); + } + // Otherwise try the possible ones + for ( String className : OntologyFactory.getFactories( formalismURI ) ) { + try { + return OntologyFactory.newInstance( className ).loadOntology( file ); + } catch ( OntowrapException owex ) { + if ( ex == null ) + ex = new OntowrapException( "Cannot load ontology "+file, owex ); + } + } + throw ex; + } + } diff --git a/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java b/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java index 57b10d2db4eaf1d02e24f1d3c6a3d663af4a2131..701e79b8696fe9e5f237dd4a7b65b3ba7c92e5c1 100644 --- a/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java +++ b/src/fr/inrialpes/exmo/ontowrap/OntologyFactory.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008, 2010 + * Copyright (C) INRIA, 2008, 2010-2011 * * 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,7 +21,12 @@ package fr.inrialpes.exmo.ontowrap; import java.net.URI; +import java.net.URISyntaxException; import java.util.Hashtable; +import java.util.Set; +import java.util.HashSet; +import java.util.Map; +import java.util.HashMap; import java.lang.reflect.InvocationTargetException; @@ -41,10 +46,43 @@ public abstract class OntologyFactory { public static final int MENTIONNED = 11; public static final int ALL = 12; + private static Map<URI,Set<String>> factories = null; + protected static Hashtable<String,OntologyFactory> instances = null; private static String API_NAME="fr.inrialpes.exmo.ontowrap.owlapi30.OWLAPI3OntologyFactory"; + public static Set<String> getFactories( URI formalism ) { + if ( factories == null ){ + factories = new HashMap<URI, Set<String>>(); + try { + HashSet<String> owl = new HashSet<String>(); + factories.put( new URI("http://www.w3.org/2002/07/owl#"), owl ); + owl.add( "fr.inrialpes.exmo.ontowrap.jena25.JENAOntologyFactory" ); + owl.add( "fr.inrialpes.exmo.ontowrap.owlapi30.OWLAPI3OntologyFactory" ); + owl.add( "fr.inrialpes.exmo.ontowrap.owlapi10.OWLAPIOntologyFactory" ); + + HashSet<String> rdfs = new HashSet<String>(); + factories.put( new URI("http://www.w3.org/2000/01/rdf-schema#"), rdfs ); + rdfs.add( "fr.inrialpes.exmo.ontowrap.jena25.JENAOntologyFactory" ); + + //HashSet<String> owl2 = new HashSet<String>(); + //factories.put( new URI("http://www.w3.org/2002/07/owl#"), owl2 ); + //owl2.add( "fr.inrialpes.exmo.ontowrap.jena25.JENAOntologyFactory" ); + //owl2.add( "fr.inrialpes.exmo.ontowrap.owlapi30.OWLAPI3OntologyFactory" ); + + HashSet<String> skos = new HashSet<String>(); + factories.put( new URI("http://www.w3.org/2004/02/skos/core#"), skos ); + skos.add( "fr.inrialpes.exmo.ontowrap.skoslite.SKOSLiteOntologyFactory" ); + skos.add( "fr.inrialpes.exmo.ontowrap.skosapi.SKOSOntologyFactory" ); + + } catch ( URISyntaxException uriex ) { + uriex.printStackTrace(); // should never occur + } + } + return factories.get( formalism ); + } + public static String getDefaultFactory(){ return API_NAME; } @@ -57,7 +95,7 @@ public abstract class OntologyFactory { return newInstance(API_NAME); } - private static OntologyFactory newInstance( String apiName ) { + protected static OntologyFactory newInstance( String apiName ) { if ( instances == null ) instances = new Hashtable<String,OntologyFactory>(); OntologyFactory of = instances.get( apiName ); if ( of != null ) return of;