Mentions légales du service

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

- reengineered matrixbased distances

parent 342bcb2a
No related branches found
No related tags found
No related merge requests found
......@@ -21,12 +21,13 @@
package fr.inrialpes.exmo.align.impl;
import java.util.Iterator;
import java.util.Vector;
import java.util.HashMap;
import java.net.URI;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLProperty;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLException;
import org.semanticweb.owl.align.Alignment;
......@@ -58,10 +59,11 @@ public abstract class MatrixMeasure implements Similarity {
public int nbprop2 = 0; // number of classes in onto2
public int i, j = 0; // index for onto1 and onto2 classes
public int l1, l2 = 0; // length of strings (for normalizing)
public Vector classlist2 = null; // onto2 classes
public Vector classlist1 = null; // onto1 classes
public Vector proplist2 = null; // onto2 classes
public Vector proplist1 = null; // onto1 classes
public HashMap classlist2 = null; // onto2 classes
public HashMap classlist1 = null; // onto1 classes
public HashMap proplist2 = null; // onto2 properties
public HashMap proplist1 = null; // onto1 properties
public double clmatrix[][]; // distance matrix
public double prmatrix[][]; // distance matrix
......@@ -73,40 +75,47 @@ public abstract class MatrixMeasure implements Similarity {
public void initialize( OWLOntology o1, OWLOntology o2 ){
onto1 = o1;
onto2 = o2;
classlist2 = new Vector(10); // onto2 classes
classlist1 = new Vector(10); // onto1 classes
proplist2 = new Vector(10); // onto2 classes
proplist1 = new Vector(10); // onto1 classes
classlist2 = new HashMap(); // onto2 classes
classlist1 = new HashMap(); // onto1 classes
proplist2 = new HashMap(); // onto2 properties
proplist1 = new HashMap(); // onto1 properties
try {
// Create class lists
for ( Iterator it = onto2.getClasses().iterator(); it.hasNext(); nbclass2++ ){
classlist2.add( it.next() );
classlist2.put( it.next(), new Integer(nbclass2) );
}
for ( Iterator it = onto1.getClasses().iterator(); it.hasNext(); nbclass1++ ){
classlist1.add( it.next() );
classlist1.put( it.next(), new Integer(nbclass1) );
}
clmatrix = new double[nbclass1+1][nbclass2+1];
// Create property lists
for ( Iterator it = onto2.getObjectProperties().iterator(); it.hasNext(); nbprop2++ ){
proplist2.add( it.next() );
proplist2.put( it.next(), new Integer(nbprop2) );
}
for ( Iterator it = onto2.getDataProperties().iterator(); it.hasNext(); nbprop2++ ){
proplist2.add( it.next() );
proplist2.put( it.next(), new Integer(nbprop2) );
}
for ( Iterator it = onto1.getObjectProperties().iterator(); it.hasNext(); nbprop1++ ){
proplist1.add( it.next() );
proplist1.put( it.next(), new Integer(nbprop1) );
}
for ( Iterator it = onto1.getDataProperties().iterator(); it.hasNext(); nbprop1++ ){
proplist1.add( it.next() );
proplist1.put( it.next(), new Integer(nbprop1) );
}
prmatrix = new double[nbprop1+1][nbprop2+1];
} catch (OWLException e) { e.printStackTrace(); };
}
public double getSimilarity( URI uri1, URI uri2 ){
public double getIndividualSimilarity( OWLIndividual i1, OWLIndividual i2 ){
// JE: non finished...
int i,j = 0;
return 0.;
}
public double getClassSimilarity( OWLClass c1, OWLClass c2 ){
return clmatrix[((Integer)classlist1.get(c1)).intValue()][((Integer)classlist2.get(c2)).intValue()];
}
public double getPropertySimilarity( OWLProperty p1, OWLProperty p2 ){
return prmatrix[((Integer)proplist1.get(p1)).intValue()][((Integer)proplist2.get(p2)).intValue()];
}
}
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