From 16b2436659901b8077aa936a5b16005151ba18a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Fri, 8 Feb 2013 14:28:22 +0000
Subject: [PATCH] - added relation sensitivity to evaluators

---
 .../inrialpes/exmo/align/impl/eval/PRecEvaluator.java | 11 +++++++----
 .../exmo/align/impl/eval/WeightedPREvaluator.java     | 11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java
index 9aa29bb4..c5faa40d 100644
--- a/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java
+++ b/src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) INRIA, 2004-2011
+ * Copyright (C) INRIA, 2004-2011, 2013
  *
  * 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
@@ -44,8 +44,7 @@ import java.net.URI;
  * This function implements Precision/Recall. The first alignment
  * is thus the expected one.
  *
- * NOTE: This measure does not take relations nor confidences into account
- * For relation, this will wait for algebra based relations
+ * Basic relation sensitivity has been implemented
  *
  * @author Jerome Euzenat
  * @version $Id$ 
@@ -61,6 +60,8 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator {
 
     protected double fmeasure = 0.;
 
+    protected boolean relsensitive = false;
+
     protected long time = 0;
 
     protected int nbexpected = 0;
@@ -109,6 +110,7 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator {
     public double eval( Properties params ) throws AlignmentException {
 	init();
 	nbfound = align2.nbCells();
+	if ( params.getProperty("relations") != null ) relsensitive = true;
 
 	for ( Cell c1 : align1 ) {
 	    URI uri1 = c1.getObject2AsURI();
@@ -117,7 +119,8 @@ public class PRecEvaluator extends BasicEvaluator implements Evaluator {
 	    if( s2 != null ){
 		for( Cell c2 : s2 ) {
 		    URI uri2 = c2.getObject2AsURI();	
-		    if ( uri1.equals( uri2 ) ) {
+		    if ( uri1.equals( uri2 )
+			 && ( !relsensitive || c1.getRelation().equals( c2.getRelation() ) ) ) {
 			nbcorrect++;
 			break;
 		    }
diff --git a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java
index 1fff7bc0..311104a8 100644
--- a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java
+++ b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java
@@ -1,7 +1,7 @@
 /*
  * $Id: WeightedPRecEvaluator.java 1494 2010-07-23 14:43:36Z euzenat $
  *
- * Copyright (C) INRIA, 2004-2012
+ * Copyright (C) INRIA, 2004-2013
  *
  * 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
@@ -44,8 +44,7 @@ import java.net.URI;
  * This function implements Precision/Recall. The first alignment
  * is thus the expected one.
  *
- * NOTE: This measure does not take relations nor confidences into account
- * For relation, this will wait for algebra based relations
+ * Basic relation sensitivity has been implemented
  *
  * @author Jerome Euzenat
  * @version $Id: PRecEvaluator.java 1494 2010-07-23 14:43:36Z euzenat $ 
@@ -61,6 +60,8 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator {
 
     protected double fmeasure = 0.;
 
+    protected boolean relsensitive = false;
+
     protected long time = 0;
 
     protected double nbexpected = 0.;
@@ -109,6 +110,7 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator {
     public double eval( Properties params ) throws AlignmentException {
 	init();
 	for ( Cell c2 : align2 ) nbfound += c2.getStrength();
+	if ( params.getProperty("relations") != null ) relsensitive = true;
 
 	for ( Cell c1 : align1 ) {
 	    URI uri1 = c1.getObject2AsURI();
@@ -117,7 +119,8 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator {
 	    if( s2 != null ){
 		for( Cell c2 : s2 ) {
 		    URI uri2 = c2.getObject2AsURI();	
-		    if ( uri1.equals( uri2 ) ) {
+		    if ( uri1.equals( uri2 )
+			 && ( !relsensitive || c1.getRelation().equals( c2.getRelation() ) ) ) {
 			double diff = c1.getStrength() - c2.getStrength();
 			nbcorrect += 1. - ((diff>0.)?diff:-diff);
 			break;
-- 
GitLab