Mentions légales du service

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

- Added autoselecting BasicOntology.load()

parent 2dea2a28
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,7 @@ The development of 4 versions continues. ...@@ -65,6 +65,7 @@ The development of 4 versions continues.
<li>Added <tt>WeightedPRecEvaluator</tt> weighting confidences (eval)</li> <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 <tt>toURIAlignment</tt> and <tt>toEDOALAlignment</tt> for <tt>EDOALAlignment</tt> (edoal)</li>
<li>Added matching test generator facility (gen)</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>Suppressed <tt>EDOALRelation</tt>: EDOAL uses <tt>BasicRelation</tt> (edoal)</li>
<li>EDOAL default printout now uses pretty relations, i.e., &lt;, &gt;, =, % (edoal)</li> <li>EDOAL default printout now uses pretty relations, i.e., &lt;, &gt;, =, % (edoal)</li>
<li>Changed order of display to precision/F-measure/recall (util)</li> <li>Changed order of display to precision/F-measure/recall (util)</li>
......
/* /*
* $Id$ * $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 * 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 * 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> { ...@@ -60,4 +60,25 @@ public class BasicOntology<O> implements Ontology<O> {
} }
return result; 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;
}
} }
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2008, 2010 * Copyright (C) INRIA, 2008, 2010-2011
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
...@@ -21,7 +21,12 @@ ...@@ -21,7 +21,12 @@
package fr.inrialpes.exmo.ontowrap; package fr.inrialpes.exmo.ontowrap;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.util.Hashtable; 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; import java.lang.reflect.InvocationTargetException;
...@@ -41,10 +46,43 @@ public abstract class OntologyFactory { ...@@ -41,10 +46,43 @@ public abstract class OntologyFactory {
public static final int MENTIONNED = 11; public static final int MENTIONNED = 11;
public static final int ALL = 12; public static final int ALL = 12;
private static Map<URI,Set<String>> factories = null;
protected static Hashtable<String,OntologyFactory> instances = null; protected static Hashtable<String,OntologyFactory> instances = null;
private static String API_NAME="fr.inrialpes.exmo.ontowrap.owlapi30.OWLAPI3OntologyFactory"; 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(){ public static String getDefaultFactory(){
return API_NAME; return API_NAME;
} }
...@@ -57,7 +95,7 @@ public abstract class OntologyFactory { ...@@ -57,7 +95,7 @@ public abstract class OntologyFactory {
return newInstance(API_NAME); return newInstance(API_NAME);
} }
private static OntologyFactory newInstance( String apiName ) { protected static OntologyFactory newInstance( String apiName ) {
if ( instances == null ) instances = new Hashtable<String,OntologyFactory>(); if ( instances == null ) instances = new Hashtable<String,OntologyFactory>();
OntologyFactory of = instances.get( apiName ); OntologyFactory of = instances.get( apiName );
if ( of != null ) return of; if ( of != null ) return of;
......
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