From ae36cffe1b4ffab744ef051188ae41e5864ec2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Mon, 12 Jul 2010 13:32:24 +0000 Subject: [PATCH] - Make ontowrap interfaces even more able to raise exceptions --- html/relnotes.html | 17 +++--- .../exmo/align/impl/eval/ExtPREvaluator.java | 6 +- .../impl/method/ClassStructAlignment.java | 55 ++++++++++--------- .../impl/method/NameAndPropertyAlignment.java | 42 +++++++------- .../impl/method/StrucSubsDistAlignment.java | 53 ++++++++++-------- .../exmo/ontowrap/HeavyLoadedOntology.java | 22 ++++---- 6 files changed, 108 insertions(+), 87 deletions(-) diff --git a/html/relnotes.html b/html/relnotes.html index 8ceb192e..c5e515ee 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -17,8 +17,8 @@ <h2>Plan for release 5 (you can comment)</h2> <p> -The next major release, release 5, is now in sight due to various -constraints and needs that have arousen in the past months. Here are +The next major release, release 5, is under design progressively under +version 4. Here are the main ruptures that will appear: <ul compact="1"> <li>The use of Java 1.5 parametrization facilities for refining the @@ -31,13 +31,12 @@ Other less radical changes include: <ul compact="1"> <li>Implementation of <tt>Relation</tt> and <tt>Confidence</tt> interfaces </li> </ul> -The development and maintainance of 4 versions continue. +The development of 4 versions continue. </p> <h2>Under development (you can contribute)</h2> <p><ul compact="1"> -<li>Integration of SKOS API (ontowrap)</li> <li>Implement full OWL rendering of EDOAL (impl)</li> <li>Adding type checking to EDOAL parser (parser)</li> <li>Implement fully relaxed precision and recall (impl)</li> @@ -46,8 +45,7 @@ The development and maintainance of 4 versions continue. <li>Complete tutorial4 with distributed reasoning.</li> <li>Genericize evaluators in <tt>GraphEvaluator</tt> and <tt>GenPlot</tt> (eval)</li> <li>Implementation of a provenance metadata tag (server/impl)</li> -<li>Providing a <tt>DiffAlign( al1, al2 )</tt> operation and interface - (util)</li> +<li>Providing a <tt>DiffAlign( al1, al2 )</tt> evaluator (impl) and interface (util)</li> <li>Replace <tt>DistanceAlignment</tt> with a version more in line with OntoSim (impl)</tt> <li>Improve HTML interface layout and usability (server)</li> @@ -67,11 +65,16 @@ The development and maintainance of 4 versions continue. <!--h2>Version 4.1 (1xxx): xx/09/2009 - Tring</h2--> <p><ul compact="1"> +<li>Integration of SKOS API (ontowrap)</li> +<li>Extended ontowrap so that all methods can raise exceptions (ontowrap)</li> <li>Added a <tt>getResult()</tt> method to <tt>Evaluator</tt> (api)</li> <li>Implemented online evaluation (server)</li> <!--li>Implemented transformations in EDOAL (edoal)</li--> +<li><tt>edoal:or</tt>, <tt>edoal:and</tt> and <tt>edoal:compose</tt> + can be empty (edoal)</li> <li>Upgraded to <span style="color: green">Pellet 2.1</span> (lib)</li> -<li>Added tutorial 4 Pellet action (tutorial)</li> +<li>Added <a href="tutorial/tutorial4/index.html">tutorial 4</a> Pellet action (tutorial)</li> +<li>Added <a href="tutorial/tutorial5/index.html">tutorial 5</a> about exposing matchers as web services (tutorial)</li> <li>Fixed path errors in tutorials (tutorial)</li> <li>Improved RDF Rendering layout (impl)</li> </ul></p> diff --git a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java index 198fcada..a15ab83d 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java @@ -232,7 +232,11 @@ public class ExtPREvaluator extends BasicEvaluator implements Evaluator { } public boolean isSuperProperty( Object prop1, Object prop2, HeavyLoadedOntology<Object> ontology ) throws AlignmentException { - return ontology.getSuperProperties( prop2, OntologyFactory.DIRECT, OntologyFactory.ANY, OntologyFactory.ANY ).contains( prop1 ); + try { + return ontology.getSuperProperties( prop2, OntologyFactory.DIRECT, OntologyFactory.ANY, OntologyFactory.ANY ).contains( prop1 ); + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Cannot interpret isSuperProperty", owex ); + } } diff --git a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java index 50b63689..5bf292b5 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/ClassStructAlignment.java @@ -134,38 +134,43 @@ public class ClassStructAlignment extends DistanceAlignment implements Alignment // + pic2 * 2 * // (sigma (att in c[i]) getAllignCell... ) // / nbatts of c[i] + nbatts of c[j] - for ( i=0; i<nbclass1; i++ ){ - Set<? extends Object> properties1 = honto1.getProperties( classlist1.get(i), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); - int nba1 = properties1.size(); - if ( nba1 > 0 ) { // if not, keep old values... - //Set correspondences = new HashSet(); - for ( j=0; j<nbclass2; j++ ){ - Set<? extends Object> properties2 = honto2.getProperties( classlist2.get(j), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); - int nba2 = properties2.size(); - double attsum = 0.; - // check that there is a correspondance - // in list of class2 atts and add their weights - for ( Object prp : properties1 ){ - Set<Cell> s2 = getAlignCells1( prp ); - // Find the property with the higest similarity - // that is matched here - double currentValue = 0.; - if ( s2 != null ) { - for( Cell c2 : s2 ){ - if ( properties2.contains( c2.getObject2() ) ) { - double val = c2.getStrength(); - if ( val > currentValue ) - currentValue = val; + try { + for ( i=0; i<nbclass1; i++ ){ + Set<? extends Object> properties1 = honto1.getProperties( classlist1.get(i), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); + int nba1 = properties1.size(); + if ( nba1 > 0 ) { // if not, keep old values... + //Set correspondences = new HashSet(); + for ( j=0; j<nbclass2; j++ ){ + Set<? extends Object> properties2 = honto2.getProperties( classlist2.get(j), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); + int nba2 = properties2.size(); + double attsum = 0.; + // check that there is a correspondance + // in list of class2 atts and add their weights + for ( Object prp : properties1 ){ + Set<Cell> s2 = getAlignCells1( prp ); + // Find the property with the higest similarity + // that is matched here + double currentValue = 0.; + if ( s2 != null ) { + for( Cell c2 : s2 ){ + if ( properties2.contains( c2.getObject2() ) ) { + double val = c2.getStrength(); + if ( val > currentValue ) + currentValue = val; + } } } + attsum = attsum + 1 - currentValue; } - attsum = attsum + 1 - currentValue; + classmatrix[i][j] = classmatrix[i][j] + + pic2 * (2 * attsum / (nba1 + nba2)); } - classmatrix[i][j] = classmatrix[i][j] - + pic2 * (2 * attsum / (nba1 + nba2)); } } + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Cannot navigate properties", owex ); } + } } diff --git a/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java index c271e141..5616178a 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/NameAndPropertyAlignment.java @@ -190,29 +190,33 @@ public class NameAndPropertyAlignment extends DistanceAlignment implements Align // + pic2 * 2 * // (sigma (att in c[i]) getAllignCell... ) // / nbatts of c[i] + nbatts of c[j] - - for ( i=0; i<nbclass1; i++ ){ - Set<? extends Object> properties1 = honto1.getProperties( classlist1.get(i), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); - - int nba1 = properties1.size(); - if ( nba1 > 0 ) { // if not, keep old values... - //Set correspondences = new HashSet(); - for ( j=0; j<nbclass2; j++ ){ - Set<? extends Object> properties2 = honto2.getProperties( classlist2.get(j), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); - //int nba2 = properties1.size(); - //double attsum = 0.; - // check that there is a correspondance - // in list of class2 atts and add their weights - - // Make a local alignment with the properties. - double moy_align_loc = alignLocal(properties1,properties2); - - if (moy_align_loc > 0.7){ - classmatrix[i][j] = (classmatrix[i][j] + 2* moy_align_loc)/3; + try { + for ( i=0; i<nbclass1; i++ ){ + Set<? extends Object> properties1 = honto1.getProperties( classlist1.get(i), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); + + int nba1 = properties1.size(); + if ( nba1 > 0 ) { // if not, keep old values... + //Set correspondences = new HashSet(); + for ( j=0; j<nbclass2; j++ ){ + Set<? extends Object> properties2 = honto2.getProperties( classlist2.get(j), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); + //int nba2 = properties1.size(); + //double attsum = 0.; + // check that there is a correspondance + // in list of class2 atts and add their weights + + // Make a local alignment with the properties. + double moy_align_loc = alignLocal(properties1,properties2); + + if (moy_align_loc > 0.7){ + classmatrix[i][j] = (classmatrix[i][j] + 2* moy_align_loc)/3; + } } } } + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Cannot navigate properties", owex ); } + // Assess factor // -- FirstExp: nothing to be done: one pass diff --git a/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java index 32d9f232..39946008 100644 --- a/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/method/StrucSubsDistAlignment.java @@ -194,36 +194,41 @@ public class StrucSubsDistAlignment extends DistanceAlignment implements Alignme // + pic2 * 2 * // (sigma (att in c[i]) getAllignCell... ) // / nbatts of c[i] + nbatts of c[j] - for ( i=0; i<nbclass1; i++ ){ - Set<? extends Object> properties1 = honto1.getProperties( classlist1.get(i), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); - int nba1 = properties1.size(); - if ( nba1 > 0 ) { // if not, keep old values... - //Set correspondences = new HashSet(); - for ( j=0; j<nbclass2; j++ ){ - Set<? extends Object> properties2 = honto2.getProperties( classlist2.get(j), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); - int nba2 = properties2.size(); - double attsum = 0.; - // check that there is a correspondance - // in list of class2 atts and add their weights - for ( Object prp : properties1 ){ - Set<Cell> s2 = getAlignCells1( prp ); - // Find the property with the higest similarity - // that is matched here - double currentValue = 0.; - for( Cell c2 : s2 ){ - if ( properties2.contains( c2.getObject2() ) ) { - double val = c2.getStrength(); - if ( val > currentValue ) - currentValue = val; + try { + for ( i=0; i<nbclass1; i++ ){ + Set<? extends Object> properties1 = honto1.getProperties( classlist1.get(i), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); + int nba1 = properties1.size(); + if ( nba1 > 0 ) { // if not, keep old values... + //Set correspondences = new HashSet(); + for ( j=0; j<nbclass2; j++ ){ + Set<? extends Object> properties2 = honto2.getProperties( classlist2.get(j), OntologyFactory.ANY, OntologyFactory.ANY, OntologyFactory.ANY ); + int nba2 = properties2.size(); + double attsum = 0.; + // check that there is a correspondance + // in list of class2 atts and add their weights + for ( Object prp : properties1 ){ + Set<Cell> s2 = getAlignCells1( prp ); + // Find the property with the higest similarity + // that is matched here + double currentValue = 0.; + for( Cell c2 : s2 ){ + if ( properties2.contains( c2.getObject2() ) ) { + double val = c2.getStrength(); + if ( val > currentValue ) + currentValue = val; + } } + attsum = attsum + 1 - currentValue; } - attsum = attsum + 1 - currentValue; + classmatrix[i][j] = classmatrix[i][j] + + pic2 * (2 * attsum / (nba1 + nba2)); } - classmatrix[i][j] = classmatrix[i][j] - + pic2 * (2 * attsum / (nba1 + nba2)); } } + } catch ( OntowrapException owex ) { + throw new AlignmentException( "Error accessing ontology", owex ); } + // Assess factor // -- FirstExp: nothing to be done: one pass factor = 0.; diff --git a/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java b/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java index 0e4589d9..de47756f 100644 --- a/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java @@ -32,23 +32,23 @@ import java.util.Set; public interface HeavyLoadedOntology<O> extends LoadedOntology<O> { /* Capability methods */ - public boolean getCapabilities( int Direct, int Asserted, int Named ); + public boolean getCapabilities( int Direct, int Asserted, int Named ) throws OntowrapException; /* Class methods */ public <E >Set<E> getSubClasses( E c, int local, int asserted, int named ); - public Set<? extends Object> getSuperClasses( Object c, int local, int asserted, int named ); - public Set<? extends Object> getProperties( Object c, int local, int asserted, int named ); - public Set<? extends Object> getDataProperties( Object c, int local, int asserted, int named ); - public Set<? extends Object> getObjectProperties( Object c, int local, int asserted, int named ); - public Set<? extends Object> getInstances( Object c, int local, int asserted, int named ); + public Set<? extends Object> getSuperClasses( Object c, int local, int asserted, int named ) throws OntowrapException; + public Set<? extends Object> getProperties( Object c, int local, int asserted, int named ) throws OntowrapException; + public Set<? extends Object> getDataProperties( Object c, int local, int asserted, int named ) throws OntowrapException; + public Set<? extends Object> getObjectProperties( Object c, int local, int asserted, int named ) throws OntowrapException; + public Set<? extends Object> getInstances( Object c, int local, int asserted, int named ) throws OntowrapException; /* Property methods */ - public Set<? extends Object> getSubProperties( Object p, int local, int asserted, int named ); - public Set<? extends Object> getSuperProperties( Object p, int local, int asserted, int named ); - public Set<? extends Object> getRange( Object p, int asserted ); - public Set<? extends Object> getDomain( Object p, int asserted ); + public Set<? extends Object> getSubProperties( Object p, int local, int asserted, int named ) throws OntowrapException; + public Set<? extends Object> getSuperProperties( Object p, int local, int asserted, int named ) throws OntowrapException; + public Set<? extends Object> getRange( Object p, int asserted ) throws OntowrapException; + public Set<? extends Object> getDomain( Object p, int asserted ) throws OntowrapException; /* Individual methods */ - public Set<? extends Object> getClasses( Object i, int local, int asserted, int named ); + public Set<? extends Object> getClasses( Object i, int local, int asserted, int named ) throws OntowrapException; } -- GitLab