All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.coode.oppl.similarity.OWLObjectStructuralPrimeHashingBasedSimilarityMeasure Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package org.coode.oppl.similarity;

import org.semanticweb.owlapi.model.OWLObject;

/** This measure is based on an Hashing function that maps each OWLObject into a
 * product of prime numbers. Prime number factorization is unique, hence
 * dividing the hash codes one can easily spot the differences.
 * 
 * @author Luigi Iannone */
public class OWLObjectStructuralPrimeHashingBasedSimilarityMeasure implements
        SimilarityMeasure {
    private final HashFunction hashFunction = new StructuralHashFunction();

    @Override
    public double compare(OWLObject anObject, OWLObject anotherObject) {
        double anObjectHashValue = getHashFunction().getHashCode(anObject);
        double anotherObjectHashValue = getHashFunction().getHashCode(anotherObject);
        return anObjectHashValue > anotherObjectHashValue ? anotherObjectHashValue
                / anObjectHashValue : anObjectHashValue / anotherObjectHashValue;
    }

    @Override
    public boolean isSymmetric() {
        return true;
    }

    /** @return the hashFunction */
    public HashFunction getHashFunction() {
        return hashFunction;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy