From 0887e61ad1f8c52d341ca9f676d8c2f17316bbe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Mon, 30 May 2011 19:57:10 +0000 Subject: [PATCH] - Set precision to 1.0 when alignment is empty --- .../exmo/align/impl/eval/PRecEvaluator.java | 4 +-- .../align/impl/eval/WeightedPREvaluator.java | 16 ++--------- test/src/READMETest.java | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java index c6870613..9aa29bb4 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java @@ -81,8 +81,8 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator { } public void init(){ - precision = 0.; - recall = 0.; + precision = 1.; + recall = 1.; overall = 0.; fmeasure = 0.; time = 0; diff --git a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java index 0eb2e593..25463e30 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java @@ -63,13 +63,10 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { protected long time = 0; - // WPR protected double nbexpected = 0.; - // WPR protected double nbfound = 0.; - // WPR protected double nbcorrect = 0.; // nb of cells correctly identified /** Creation @@ -84,12 +81,11 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { } public void init(){ - precision = 0.; - recall = 0.; + precision = 1.; + recall = 1.; overall = 0.; fmeasure = 0.; time = 0; - // WPR nbexpected = 0.; nbfound = 0.; nbcorrect = 0.; @@ -112,22 +108,16 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { */ public double eval( Properties params ) throws AlignmentException { init(); - // WPR - //nbfound = align2.nbCells(); for ( Cell c2 : align2 ) nbfound += c2.getStrength(); for ( Cell c1 : align1 ) { URI uri1 = c1.getObject2AsURI(); - // WPR - //nbexpected++; nbexpected += c1.getStrength(); Set<Cell> s2 = align2.getAlignCells1( c1.getObject1() ); if( s2 != null ){ for( Cell c2 : s2 ) { URI uri2 = c2.getObject2AsURI(); if ( uri1.equals( uri2 ) ) { - // WPR - //nbcorrect++; double diff = c1.getStrength() - c2.getStrength(); nbcorrect += 1. - ((diff>0.)?diff:-diff); break; @@ -221,7 +211,6 @@ return result; results.setProperty( "recall", Double.toString( recall ) ); results.setProperty( "overall", Double.toString( overall ) ); results.setProperty( "fmeasure", Double.toString( fmeasure ) ); - // WPR results.setProperty( "nbexpected", Double.toString( nbexpected ) ); results.setProperty( "nbfound", Double.toString( nbfound ) ); results.setProperty( "true positive", Double.toString( nbcorrect ) ); @@ -236,7 +225,6 @@ return result; public double getNoise() { return 1.-precision; } public double getSilence() { return 1.-precision; } public double getFmeasure() { return fmeasure; } - // WPR public double getExpected() { return nbexpected; } public double getFound() { return nbfound; } public double getCorrect() { return nbcorrect; } diff --git a/test/src/READMETest.java b/test/src/READMETest.java index 42f64618..bb82d036 100644 --- a/test/src/READMETest.java +++ b/test/src/READMETest.java @@ -259,6 +259,33 @@ $ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.EvalAlign -i fr.inrial //assertEquals( eval.getResult(), 1.34375 ); } + @Test(groups = { "full", "impl", "raw" }, dependsOnMethods = {"routineTest8"}) + public void emptyEvalTest() throws Exception { + /* +$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.EvalAlign -i fr.inrialpes.exmo.align.impl.eval.PRecEvaluator file://$CWD/examples/rdf/bibref2.rdf file://$CWD/examples/rdf/bibref.rdf + */ + AlignmentParser aparser1 = new AlignmentParser( 0 ); + assertNotNull( aparser1 ); + Alignment align1 = aparser1.parse( "test/output/bibref2.rdf" ); + assertNotNull( align1 ); + aparser1.initAlignment( null ); + Alignment align2 = new ObjectAlignment(); + assertNotNull( align2 ); + align2.init( align1.getOntology1URI(), align1.getOntology2URI() ); + Properties params = new Properties(); + assertNotNull( params ); + PRecEvaluator eval = new PRecEvaluator( align1, align2 ); + assertNotNull( eval ); + eval.eval( params ) ; + + assertEquals( eval.getPrecision(), 1.); + assertEquals( eval.getRecall(), 0.0 ); + assertEquals( eval.getNoise(), 0.); + assertEquals( eval.getFmeasure(), 0.); + assertEquals( eval.getOverall(), 0.); + //assertEquals( eval.getResult(), 0. ); + } + @Test(expectedExceptions = AlignmentException.class, groups = {"full", "impl", "raw" }, dependsOnMethods = {"routineEvalTest"}) public void routineErrorEvalTest() throws Exception { AlignmentParser aparser1 = new AlignmentParser( 0 ); -- GitLab