From f8dc574a438f05f0d1b5ab246e152035bbbb03d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Thu, 12 Feb 2009 15:53:35 +0000
Subject: [PATCH] - adapted test for new cut(.)

---
 test/src/BasicAlignmentTest.java | 10 ++++---
 test/src/JWNLTest.java           |  2 +-
 test/src/MatcherTest.java        |  2 +-
 test/src/READMETest.java         | 45 +++++++++++++++++++++++++++-----
 4 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/test/src/BasicAlignmentTest.java b/test/src/BasicAlignmentTest.java
index 359e7478..5434b839 100644
--- a/test/src/BasicAlignmentTest.java
+++ b/test/src/BasicAlignmentTest.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) INRIA, 2008
+ * Copyright (C) INRIA, 2008-2009
  *
  * 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
@@ -28,14 +28,16 @@ import org.testng.annotations.Configuration;
 import org.testng.annotations.Test;
 //import org.testng.annotations.*;
 
-import fr.inrialpes.exmo.align.impl.OWLAPIAlignment;
+import fr.inrialpes.exmo.align.impl.BasicAlignment;
+
+import org.semanticweb.owl.align.Alignment;
 
 public class BasicAlignmentTest {
-    private OWLAPIAlignment alignment = null;
+    private Alignment alignment = null;
 
     @BeforeClass(groups = { "full", "noling" })
     private void init(){
-	alignment = new OWLAPIAlignment();
+	alignment = new BasicAlignment();
     }
 
     @Test(groups = { "full", "noling" })
diff --git a/test/src/JWNLTest.java b/test/src/JWNLTest.java
index c0400c9b..6f087b17 100644
--- a/test/src/JWNLTest.java
+++ b/test/src/JWNLTest.java
@@ -79,7 +79,7 @@ $ java -jar lib/alignwn.jar -D=$WNDIR file://$CWD/examples/rdf/ file://$CWD/exam
 	writer.close();
 	assertEquals( stream.toString().length(), 14027, "Rendered differently" );
 	alignment.cut( "hard", 0.4 );
-	assertEquals( alignment.nbCells(), 37 );
+	assertEquals( alignment.nbCells(), 38 );
 
 	// Different similarity
 	params.setParameter( "wnfunction", "cosynonymySimilarity" );
diff --git a/test/src/MatcherTest.java b/test/src/MatcherTest.java
index e5bf79e4..f2ce2ad9 100644
--- a/test/src/MatcherTest.java
+++ b/test/src/MatcherTest.java
@@ -93,7 +93,7 @@ $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publica
 $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publication.owl file://$CWD/examples/rdf/edu.mit.visus.bibtex.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=subStringDistance -t .4 -o examples/rdf/bibref2.rdf
 	*/
 	alignment.cut( "hard", 0.55 );
-	assertEquals( alignment.nbCells(), 32 ); /* With  .4, I have either 36 or 35! */
+	assertEquals( alignment.nbCells(), 33 ); /* With  .4, I have either 36 or 35! */
 	stream = new FileOutputStream("test/output/bibref2.rdf");
 	writer = new PrintWriter (
 			  new BufferedWriter(
diff --git a/test/src/READMETest.java b/test/src/READMETest.java
index 17ff2204..3d959c13 100644
--- a/test/src/READMETest.java
+++ b/test/src/READMETest.java
@@ -100,7 +100,7 @@ $ java -jar lib/procalign.jar file://$CWD/examples/rdf/onto1.owl file://$CWD/exa
 	/*
 $ java -jar lib/procalign.jar file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance -t 0.4 -o examples/rdf/sample.rdf
 	*/
-	alignment.cut( "hard", 0.4 );
+	alignment.cut( "hard", 0.5 );
 	assertEquals( alignment.nbCells(), 2 );
     }
 
@@ -172,8 +172,9 @@ $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publica
 	/*
 $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publication.owl file://$CWD/examples/rdf/edu.mit.visus.bibtex.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=subStringDistance -t .4 -o examples/rdf/bibref2.rdf
 	*/
+	Alignment al2 = (Alignment)alignment.clone();
 	alignment.cut( "hard", 0.55 );
-	assertEquals( alignment.nbCells(), 32 ); /* With  .4, I have either 36 or 35! */
+	assertEquals( alignment.nbCells(), 33 ); /* With  .4, I have either 36 or 35! */
 	stream = new FileOutputStream("test/output/bibref2.rdf");
 	writer = new PrintWriter (
 			  new BufferedWriter(
@@ -182,6 +183,38 @@ $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publica
 	writer.flush();
 	writer.close();
 	//assertEquals( stream.toString().length(), 1740, "Rendered differently" );
+
+	// Tests of cutting
+	Alignment al = (Alignment)al2.clone();
+	al.cut( "hard", 0.55 );
+	assertEquals( al.nbCells(), 33 );
+	al = (Alignment)al2.clone();
+	al.cut( "best", 0.55 );
+	assertEquals( al.nbCells(), 43 );
+	al = (Alignment)al2.clone();
+	al.cut( "span", 0.55 );
+	assertEquals( al.nbCells(), 34 );
+	al = (Alignment)al2.clone();
+	al.cut( "prop", 0.55 );
+	assertEquals( al.nbCells(), 33 );
+	al = (Alignment)al2.clone();
+	al.cut( "prop", 0.55 );
+	assertEquals( al.nbCells(), 33 );
+	al = (Alignment)al2.clone();
+	al.cut( "perc", 0.55 );
+	assertEquals( al.nbCells(), 23 );
+	al = (Alignment)al2.clone();
+	al.cut( "hardgap", 0.5 );
+	assertEquals( al.nbCells(), 43 );
+	al = (Alignment)al2.clone();
+	al.cut( "propgap", 0.55 );
+	assertEquals( al.nbCells(), 43 );
+
+    }
+
+    @Test(expectedExceptions = AlignmentException.class, groups = {"full", "impl", "noling" }, dependsOnMethods = {"routineTest8"})
+    public void routineErrorTest8() throws Exception {
+	alignment.cut( "prec", 0.55 );
     }
 
     @Test(groups = { "full", "impl", "noling" }, dependsOnMethods = {"routineTest8"})
@@ -210,11 +243,11 @@ $ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.EvalAlign -i fr.inrial
 	eval.write( writer );
 	writer.flush();
 	writer.close();
-	assertEquals( eval.getPrecision(), 0.7441860465116279 );
+	assertEquals( eval.getPrecision(), 0.7674418604651163 );
 	assertEquals( eval.getRecall(), 1.0 );
-	assertEquals( eval.getFallout(), 0.2558139534883721 );
-	assertEquals( eval.getFmeasure(), 0.8533333333333333 );
-	assertEquals( eval.getOverall(), 0.65625 );
+	assertEquals( eval.getFallout(), 0.23255813953488372 );
+	assertEquals( eval.getFmeasure(), 0.868421052631579 );
+	assertEquals( eval.getOverall(), 0.696969696969697 );
 	//assertEquals( eval.getResult(), 1.34375 );
     }
 
-- 
GitLab