org.jbpt.bp.sim.OrderSimilarity 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
* order relation.
*
* @author matthias.weidlich
*
*/
public class OrderSimilarity, M extends IEntityModel, N extends IEntity> extends AbstractRelSetSimilarity {
public double score(Alignment alignment) {
double in1 = super.getSizeOfRelation(alignment.getFirstModel(), RelSetType.Order);
double in2 = super.getSizeOfRelation(alignment.getSecondModel(), RelSetType.Order);
double intersection = super.getSizeOfIntersectionOfRelation(alignment, RelSetType.Order);
return (intersection > 0) ? (intersection / (in1 + in2 - intersection)) : 0;
}
public double scoreDice(Alignment alignment) {
double in1 = super.getSizeOfRelation(alignment.getFirstModel(), RelSetType.Order);
double in2 = super.getSizeOfRelation(alignment.getSecondModel(), RelSetType.Order);
double intersection = super.getSizeOfIntersectionOfRelation(alignment, RelSetType.Order);
return (in1 + in2 > 0) ? (2*intersection / (in1 + in2)) : 0;
}
}