Mentions légales du service

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

- corrected bugs in the cut() function

parent 9c3984a3
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
<p><ul compact="1"> <p><ul compact="1">
<li>Moved sources to gforge.inria.fr</li> <li>Moved sources to gforge.inria.fr</li>
<li>Moved web site to alignapi.gforge.inria.fr</li> <li>Moved web site to alignapi.gforge.inria.fr</li>
<li>Updated documentation to reflect new source location</li>
<li>Corrected cut behavior (did not cut the last item, best did not work)</li>
</ul></p> </ul></p>
<h2>February 17th, 2006</h2> <h2>February 17th, 2006</h2>
......
...@@ -367,11 +367,13 @@ public class BasicAlignment implements Alignment { ...@@ -367,11 +367,13 @@ public class BasicAlignment implements Alignment {
/*************************************************************************** /***************************************************************************
* Cut refinement : * Cut refinement :
* - above n (hard) * - getting those cells with strength above n (hard)
* - above n under the best () * - getting the n best cells (best)
* - getting the n% better (perc) * - getting those cells with strength at worse n under the best (span)
* - getting the under n% of the best (prop) * - getting the n% best cells (perc)
* - getting the n best values * - getting those cells with strength at worse n% of the best (prop)
* Rule:
* threshold is betweew 1 and 0
**************************************************************************/ **************************************************************************/
public void cut( String method, double threshold ) throws AlignmentException public void cut( String method, double threshold ) throws AlignmentException
{ {
...@@ -380,35 +382,34 @@ public class BasicAlignment implements Alignment { ...@@ -380,35 +382,34 @@ public class BasicAlignment implements Alignment {
throw new AlignmentException( "Not a percentage or threshold : "+threshold ); throw new AlignmentException( "Not a percentage or threshold : "+threshold );
// Create a sorted list of cells // Create a sorted list of cells
// For sure with sorted lists, we could certainly do far better // For sure with sorted lists, we could certainly do far better
// Raph: this will not work anymore
// JE**: did we know if it still works???
List buffer = getArrayElements(); List buffer = getArrayElements();
Collections.sort( buffer ); Collections.sort( buffer );
int size = buffer.size(); int size = buffer.size();
System.err.println( method+"("+threshold+")" );
for (int i=0; i < size ; i++ ) {
BasicCell c = (BasicCell)buffer.get(i);
System.err.println( "["+c.getStrength()+"]"+c.getObject1()+" "+c.getRelation()+" "+c.getObject2() );
}
boolean found = false; boolean found = false;
int i = 0; int i = 0; // the number of cells to keep
// Depending on the method, find the limit // Depending on the method, find the limit
if ( method.equals("hard") ){ if ( method.equals("perc") ){
for( i=0; i < size && !found ; i++ ) {
if ( ((Cell)buffer.get(i)).getStrength() <= threshold ) found = true;
}
} else if ( method.equals("span") ){
double max = ((Cell)buffer.get(0)).getStrength() -threshold;
for( i=0; i < size && !found ; i++ ) {
if ( ((Cell)buffer.get(i)).getStrength() <= max ) found = true;
}
} else if ( method.equals("prop") ){
double max = ((Cell)buffer.get(0)).getStrength() * (1-threshold);
for( i=0; i < size && !found ; i++ ) {
if ( ((Cell)buffer.get(i)).getStrength() <= max ) found = true;
}
} else if ( method.equals("perc") ){
i = (new Double(size*threshold)).intValue(); i = (new Double(size*threshold)).intValue();
} else if ( method.equals("best") ){ } else if ( method.equals("best") ){
i=(new Double(threshold)).intValue(); i = new Double(threshold*100).intValue();
} else throw new AlignmentException( "Not a cut specification : "+method ); } else {
double max;
if ( method.equals("hard") ) max = threshold;
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 ;) {
if ( ((Cell)buffer.get(i)).getStrength() < max ) found = true;
else i++;
}
}
// Flush the structure // Flush the structure
for( size-- ; size > i ; size-- ) buffer.remove(size); for( size-- ; size >= i ; size-- ) buffer.remove(size);
// Introduce the result back in the structure // Introduce the result back in the structure
size = i; size = i;
hash1.clear(); hash1.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment