Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4f087160 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- corrected bug affecting cut with one additional item

parent 8cd82f41
No related branches found
No related tags found
No related merge requests found
......@@ -433,7 +433,6 @@ public class BasicAlignment implements Alignment {
List<Cell> buffer = getArrayElements();
Collections.sort( buffer );
int size = buffer.size();
boolean found = false;
int i = 0; // the number of cells to keep
// Depending on the method, find the limit
if ( method.equals("perc") ){
......@@ -445,8 +444,8 @@ public class BasicAlignment implements Alignment {
double last = ((Cell)buffer.get(0)).getStrength();
if ( method.equals("propgap") ) gap = last * threshold;
else gap = threshold;
for( i=1; i < size && !found ; i++) {
if ( last - ((Cell)buffer.get(i)).getStrength() > gap ) found = true;
for( i=1; i < size ; i++ ) {
if ( last - ((Cell)buffer.get(i)).getStrength() > gap ) break;
else {
last = ((Cell)buffer.get(i)).getStrength();
if ( method.equals("propgap") ) gap = last * threshold;
......@@ -458,10 +457,9 @@ public class BasicAlignment implements Alignment {
else if ( method.equals("span") ) max = ((Cell)buffer.get(0)).getStrength() - threshold;
else if ( method.equals("prop") ) max = ((Cell)buffer.get(0)).getStrength() * threshold;
else throw new AlignmentException( "Not a cut specification : "+method );
for( i=0; i < size && !found ; i++) {
if ( ((Cell)buffer.get(i)).getStrength() < max ) found = true;
for( i=0; i < size ; i++) {
if ( ((Cell)buffer.get(i)).getStrength() < max ) break;
}
if ( i != 0 ) i--;
}
// Introduce the result back in the structure
size = i;
......
......@@ -33,6 +33,7 @@ import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.AlignmentProcess;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.Parameters;
import org.semanticweb.owl.align.Evaluator;
......@@ -102,7 +103,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.5 );
assertEquals( alignment.nbCells(), 2 );
assertEquals( alignment.nbCells(), 1 );
}
@Test(groups = { "full", "impl", "raw" })
......@@ -175,7 +176,7 @@ $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publica
*/
Alignment al2 = (Alignment)alignment.clone();
alignment.cut( "hard", 0.55 );
assertEquals( alignment.nbCells(), 33 ); /* With .4, I have either 36 or 35! */
assertEquals( alignment.nbCells(), 32 ); /* checked! */
stream = new FileOutputStream("test/output/bibref2.rdf");
writer = new PrintWriter (
new BufferedWriter(
......@@ -188,28 +189,35 @@ $ java -jar lib/Procalign.jar file://$CWD/examples/rdf/edu.umbc.ebiquity.publica
// Tests of cutting
Alignment al = (Alignment)al2.clone();
al.cut( "hard", 0.55 );
assertEquals( al.nbCells(), 33 );
assertEquals( al.nbCells(), 32 );
al = (Alignment)al2.clone();
al.cut( "best", 0.55 );
assertEquals( al.nbCells(), 44 );
al = (Alignment)al2.clone();
al.cut( "span", 0.55 );
assertEquals( al.nbCells(), 34 );
assertEquals( al.nbCells(), 33 );
al = (Alignment)al2.clone();
al.cut( "prop", 0.55 );
assertEquals( al.nbCells(), 33 );
assertEquals( al.nbCells(), 32 );
al = (Alignment)al2.clone();
al.cut( "prop", 0.55 );
assertEquals( al.nbCells(), 33 );
assertEquals( al.nbCells(), 32 );
al = (Alignment)al2.clone();
al.cut( "perc", 0.55 );
assertEquals( al.nbCells(), 24 );
al = (Alignment)al2.clone();
al.cut( "hardgap", 0.5 );
assertEquals( al.nbCells(), 44 );
al.cut( "hardgap", 0.05 );
for ( Cell c: al ) {
System.err.println("******************** "+c.getStrength() );
}
assertEquals( al.nbCells(), 10 );
al = (Alignment)al2.clone();
al.cut( "propgap", 0.55 );
assertEquals( al.nbCells(), 44 );
al.cut( "propgap", 0.1 );
assertEquals( al.nbCells(), 10 );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment