Mentions légales du service

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

- added a few statistic primitive in BasicAlignment

parent 7d77ec79
No related branches found
No related tags found
No related merge requests found
...@@ -127,6 +127,40 @@ public class BasicAlignment implements Alignment { ...@@ -127,6 +127,40 @@ public class BasicAlignment implements Alignment {
return sum; return sum;
} }
/** A few statistical primitives, undocumented **/
public double maxConfidence() {
double result = 0.;
for ( Cell c : this ) {
if ( c.getStrength() > result ) result = c.getStrength();
}
return result;
}
public double minConfidence() {
double result = 1.;
for ( Cell c : this ) {
if ( c.getStrength() < result ) result = c.getStrength();
}
return result;
}
public double avgConfidence() {
double result = 0.;
for ( Cell c : this ) {
result += c.getStrength();
}
return result/(double)nbCells();
}
public double varianceConfidence() {
double total = 0.;
double var = 0.;
for ( Cell c : this ) {
var += c.getStrength() * c.getStrength();
total += c.getStrength();
}
double avg = total / (double)nbCells();
return ( var / (double)nbCells() ) - (avg*avg) ;
}
// For standard deviation, take the square root of variance
/** Alignment methods * */ /** Alignment methods * */
public Object getOntology1() { public Object getOntology1() {
return onto1.getOntology(); return onto1.getOntology();
...@@ -722,7 +756,6 @@ public class BasicAlignment implements Alignment { ...@@ -722,7 +756,6 @@ public class BasicAlignment implements Alignment {
public void cleanUp() {} public void cleanUp() {}
} }
class MEnumeration<T> implements Enumeration<T> { class MEnumeration<T> implements Enumeration<T> {
private Enumeration<Set<T>> set = null; // The enumeration of sets private Enumeration<Set<T>> set = null; // The enumeration of sets
private Iterator<T> current = null; // The current set's enumeration private Iterator<T> current = null; // The current set's enumeration
......
...@@ -64,6 +64,10 @@ public class BasicAlignmentTest { ...@@ -64,6 +64,10 @@ public class BasicAlignmentTest {
assertNotNull( result, "URIAlignment(result) was null" ); assertNotNull( result, "URIAlignment(result) was null" );
assertTrue( result instanceof URIAlignment ); assertTrue( result instanceof URIAlignment );
assertEquals( result.nbCells(), 2, "Alignment should contain 2 cells" ); assertEquals( result.nbCells(), 2, "Alignment should contain 2 cells" );
assertEquals( ((BasicAlignment)result).minConfidence(), 0.4666666666666667 );
assertEquals( ((BasicAlignment)result).maxConfidence(), 1. );
assertEquals( ((BasicAlignment)result).avgConfidence(), 0.7333333333333334 );
assertEquals( ((BasicAlignment)result).varianceConfidence(), .07111111111111101 );
result.cut( "hard", .5 ); result.cut( "hard", .5 );
assertEquals( result.nbCells(), 1, "Alignment should contain 1 cell" ); assertEquals( result.nbCells(), 1, "Alignment should contain 1 cell" );
} }
......
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