org.jbpt.bp.sim.ExclusivenessSimilarity Maven / Gradle / Ivy
package org.jbpt.bp.sim;
import org.jbpt.alignment.Alignment;
import org.jbpt.bp.RelSet;
import org.jbpt.bp.RelSetType;
import org.jbpt.hypergraph.abs.IEntity;
import org.jbpt.hypergraph.abs.IEntityModel;
/**
* Scores two models by only assessing the overlap of their
* exclusiveness relation.
*
* @author matthias.weidlich
*
*/
public class ExclusivenessSimilarity, M extends IEntityModel, N extends IEntity> extends AbstractRelSetSimilarity {
public double score(Alignment alignment) {
double in1 = super.getSizeOfRelation(alignment.getFirstModel(), RelSetType.Exclusive);
double in2 = super.getSizeOfRelation(alignment.getSecondModel(), RelSetType.Exclusive);
double intersection = super.getSizeOfIntersectionOfRelation(alignment, RelSetType.Exclusive);
return (intersection > 0) ? (intersection / (in1 + in2 - intersection)) : 0;
}
public double scoreDice(Alignment alignment) {
double in1 = super.getSizeOfRelation(alignment.getFirstModel(), RelSetType.Exclusive);
double in2 = super.getSizeOfRelation(alignment.getSecondModel(), RelSetType.Exclusive);
double intersection = super.getSizeOfIntersectionOfRelation(alignment, RelSetType.Exclusive);
return (in1 + in2 > 0) ? (2*intersection / (in1 + in2)) : 0;
}
}