From 10b2a3f5cad9b4e93f6ab56503840db666ca22b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Fri, 10 Jul 2009 11:05:58 +0000 Subject: [PATCH] - implemented caching in JENAOntologyFactory --- html/relnotes.html | 15 ++++++------ .../exmo/align/onto/jena25/JENAOntology.java | 11 +++------ .../onto/jena25/JENAOntologyFactory.java | 23 +++++++++++++++---- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/html/relnotes.html b/html/relnotes.html index 3d8dc411..cec29977 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -51,8 +51,6 @@ Currently the development and maintainance of 3 versions continue. <li>Improve HTML interface layout and usability (server)</li> <li>Implement metadata edition (server)</li> <li>Implement correspondence selection (server)</li> -<li>Implement semantic precision and recall (impl)</li> -<li>Implement fully relaxed precision and recall (impl)</li> <li>Render alignments as module descriptions (impl)</li> <li>Implement extensive evaluation framework (impl)</li> <li>Implement debug options with log4j</li> @@ -66,11 +64,10 @@ Currently the development and maintainance of 3 versions continue. This version under development is planned for next September. It is likely to include: <ul> +<li>Implement fully relaxed precision and recall (impl)</li> <li>Integrate some basic reasoning.</li> -<li>Implementing semantic precision and recall /bug (impl).</li> -<li>Added a parameter to the OWLAxiomsRenderer so that it could render - heterogeneous axioms, like Class sameAs Property (impl).</li> <li>Bug in triming, maybe leaves one item to much (impl)</li> +<li>Integration of SKOS API (onto)</li> <li>Integration of OMWG alignments (impl)</li> <li>Replacement of <tt>Parameters</tt> by Java <tt>Property</tt> (api/impl)</li> <li>Implement database store for OMWG Language (server)</li> @@ -90,11 +87,15 @@ likely to include: <li>Reintegrated <tt>JWNLAlignment</tt> in implementation (procalign)</li> <li>Migrated to OWL API 2 as the default Ontology implementation (onto)</li> <li>Lifted OWL API 2 as <tt>HeavyLoadedOntology</tt> (onto)</li> +<li>Added cache management to <tt>JENAOntology</tt> (onto)</li> +<li>Implemented semantic precision and recall (impl).</li> <li>Added computation of MAP (Mean Average Precision) in <tt>PRGraphEvaluator</tt> (impl).</li> <li>Added pretty-printing of names in server (server)</li> <li>Added initialisation through initial alignment in <tt>MatrixMeasure</tt> (impl)</li> +<li>Added a parameter to the <tt>OWLAxiomsRendererVisitor</tt> so that it could render + heterogeneous axioms, like Class sameAs Property (impl).</li> <li>Suppressed of the <tt>OWLAPICell</tt> and <tt>OWLAPIAlignment</tt> (deprecated since version 3.3) (impl)</li> <li>Reorganised the lib directory hierarchically (build)</li> @@ -102,8 +103,8 @@ likely to include: (server)</li> <li>Corrected a bug in retrieving alignments from ontologies when the two ontologies are the same (server)</li> -<li>Corrected a bug when <tt>StringDistAignment<tt> fail to raise - exception when bad method given (impl)</tt> +<li>Corrected a bug when <tt>StringDistAlignment</tt> fail to raise + exception when bad method given (impl)</li> <!--li>Suppressed the capability to export alignments in WSML (impl/omwg)</li--> </ul> </p> diff --git a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java index 6cc576af..35480769 100644 --- a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java +++ b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java @@ -47,6 +47,9 @@ import fr.inrialpes.exmo.align.onto.LoadedOntology; public class JENAOntology extends BasicOntology<OntModel> implements LoadedOntology<OntModel>{ + // JE: this is not very Java 1.5... + // This is because of the version of Jena we use apparently + public Object getEntity(URI u) throws AlignmentException { return onto.getOntResource(u.toString()); } @@ -70,14 +73,6 @@ public class JENAOntology extends BasicOntology<OntModel> implements LoadedOntol public Set<String> getEntityAnnotations(Object o) throws AlignmentException { Set<String> annots = new HashSet<String>(); getEntityAnnotations(o,annots); - /*Iterator i = or.listComments(null); - while (i.hasNext()) { - annots.add(((LiteralImpl) i.next()).getLexicalForm()); - } - i = or.listLabels(null); - while (i.hasNext()) { - annots.add(((LiteralImpl) i.next()).getLexicalForm()); - }*/ return annots; } diff --git a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java index 1d923c23..7fd7afad 100644 --- a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java +++ b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntologyFactory.java @@ -33,21 +33,22 @@ import com.hp.hpl.jena.rdf.model.ModelFactory; import fr.inrialpes.exmo.align.onto.LoadedOntology; import fr.inrialpes.exmo.align.onto.OntologyFactory; +import fr.inrialpes.exmo.align.onto.OntologyCache; -public class JENAOntologyFactory extends OntologyFactory{ +public class JENAOntologyFactory extends OntologyFactory { private static URI formalismUri = null; private static String formalismId = "OWL1.0"; + private static OntologyCache<JENAOntology> cache = null; + public JENAOntologyFactory() { + cache = new OntologyCache<JENAOntology>(); try { formalismUri = new URI("http://www.w3.org/2002/07/owl#"); } catch (URISyntaxException ex) { ex.printStackTrace(); } // should not happen } - // No cache management so far - public void clearCache() {}; - public JENAOntology newOntology( Object ontology ) throws AlignmentException { if ( ontology instanceof OntModel ) { JENAOntology onto = new JENAOntology(); @@ -68,6 +69,7 @@ public class JENAOntologyFactory extends OntologyFactory{ // Better put in the AlignmentException of loaded throw new AlignmentException( "URI Error ", usex ); } + cache.recordOntology( onto.getURI(), onto ); return onto; } else { throw new AlignmentException( "Argument is not an OntModel: "+ontology ); @@ -75,10 +77,15 @@ public class JENAOntologyFactory extends OntologyFactory{ } public JENAOntology loadOntology( URI uri ) throws AlignmentException { + JENAOntology onto = null; + onto = cache.getOntologyFromURI( uri ); + if ( onto != null ) return onto; + onto = cache.getOntology( uri ); + if ( onto != null ) return onto; try { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null ); m.read(uri.toString()); - JENAOntology onto = new 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 @@ -90,10 +97,16 @@ public class JENAOntologyFactory extends OntologyFactory{ } //onto.setURI(new URI(m.listOntologies()getOntology(null).getURI())); onto.setOntology(m); + cache.recordOntology( uri, onto ); return onto; } catch (Exception e) { throw new AlignmentException("Cannot load "+uri, e ); } } + @Override + public void clearCache() { + cache.clear(); + }; + } -- GitLab