@@ -0,0 +1,2300 @@
+package eu.monnetproject.sim.entity;%0A%0Aimport java.util.Collection;%0Aimport java.util.List;%0Aimport java.util.Properties;%0Aimport java.util.Vector;%0Aimport eu.monnetproject.util.Logger;%0A%0Aimport eu.monnetproject.ontology.Entity;%0Aimport eu.monnetproject.sim.EntitySimilarityMeasure;%0Aimport eu.monnetproject.sim.util.Functions;%0Aimport eu.monnetproject.util.Logging;%0A%0A/**%0A * Cosine similarity of subclass vectors.%0A *%0A * @author Dennis Spohr, John McCrae%0A *%0A */%0Apublic class SubclassesCosine implements EntitySimilarityMeasure %7B%0A%0A    private Logger log = Logging.getLogger(this);%0A    private final String name = this.getClass().getName();%0A%0A    public SubclassesCosine() %7B%0A    %7D%0A%0A    public void configure(Properties properties) %7B%0A    %7D%0A%0A    @Override%0A    public double getScore(Entity srcEntity, Entity tgtEntity) %7B%0A%0A        if (!(srcEntity instanceof eu.monnetproject.ontology.Class && tgtEntity instanceof eu.monnetproject.ontology.Class)) %7B%0A            return 0.;%0A        %7D%0A%0A        Collection%3Ceu.monnetproject.ontology.Class%3E srcSubClasses = ((eu.monnetproject.ontology.Class) srcEntity).getSubClassOf();%0A        Collection%3Ceu.monnetproject.ontology.Class%3E tgtSubClasses = ((eu.monnetproject.ontology.Class) tgtEntity).getSubClassOf();%0A%0A        List%3CString%3E bag = new Vector%3CString%3E();%0A%0A        int%5B%5D srcVector = new int%5BsrcSubClasses.size() + tgtSubClasses.size()%5D;%0A        int%5B%5D tgtVector = new int%5BsrcVector.length%5D;%0A%0A        for (eu.monnetproject.ontology.Class srcCls : srcSubClasses) %7B%0A            if (bag.contains(srcCls.getURI().toString())) %7B%0A                srcVector%5Bbag.indexOf(srcCls.getURI().toString())%5D++;%0A            %7D else %7B%0A                bag.add(srcCls.getURI().toString());%0A                srcVector%5Bbag.indexOf(srcCls.getURI().toString())%5D = 1;%0A            %7D%0A        %7D%0A%0A        for (eu.monnetproject.ontology.Class tgtCls : tgtSubClasses) %7B%0A            if (bag.contains(tgtCls.getURI().toString())) %7B%0A                tgtVector%5Bbag.indexOf(tgtCls.getURI().toString())%5D++;%0A            %7D else %7B%0A                bag.add(tgtCls.getURI().toString());%0A                tgtVector%5Bbag.indexOf(tgtCls.getURI().toString())%5D = 1;%0A            %7D%0A        %7D%0A%0A        return Functions.cosine(srcVector, tgtVector);%0A%0A    %7D%0A%0A    @Override%0A    public String getName() %7B%0A        return this.name;%0A    %7D%0A%7D%0A

Add subclass metric