Mentions légales du service

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

- better documented the Hungarian alorithm guard

parent 75e38f68
No related branches found
No related tags found
No related merge requests found
...@@ -238,6 +238,7 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align ...@@ -238,6 +238,7 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align
for ( Object ob : ontology2().getClasses() ) { for ( Object ob : ontology2().getClasses() ) {
class2[j++] = ob; class2[j++] = ob;
} }
// ival indicates if all cells have the same value, or different (-1)
double ival = sim.getClassSimilarity(class1[0],class2[0]); double ival = sim.getClassSimilarity(class1[0],class2[0]);
for( i = 0; i < nbclasses1; i++ ){ for( i = 0; i < nbclasses1; i++ ){
for( j = 0; j < nbclasses2; j++ ){ for( j = 0; j < nbclasses2; j++ ){
...@@ -247,22 +248,22 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align ...@@ -247,22 +248,22 @@ public abstract class DistanceAlignment extends ObjectAlignment implements Align
} }
} }
// Pass it to the algorithm // Pass it to the algorithm
if ( ival == -1. ) { if ( ival == -1. ) { // if values are the same, return an empty alignment
int[][] result = HungarianAlgorithm.hgAlgorithm( matrix, "max" ); int[][] result = HungarianAlgorithm.hgAlgorithm( matrix, "max" );
// Extract the result // Extract the result
for( i=0; i < result.length ; i++ ){ for( i=0; i < result.length ; i++ ){
// The matrix has been destroyed // The matrix has been destroyed
double val; double val;
if ( sim.getSimilarity() ) val = sim.getClassSimilarity(class1[result[i][0]],class2[result[i][1]]); if ( sim.getSimilarity() ) val = sim.getClassSimilarity(class1[result[i][0]],class2[result[i][1]]);
else val = 1 - sim.getClassSimilarity(class1[result[i][0]],class2[result[i][1]]); else val = 1 - sim.getClassSimilarity(class1[result[i][0]],class2[result[i][1]]);
// JE: here using strict-> is a very good idea. // JE: here using strict-> is a very good idea.
// it means that alignments with 0. similarity // it means that correspondences with 0. similarity
// will be excluded from the best match. // will be excluded from the best match.
if( val > threshold ){ if( val > threshold ){
addCell( new ObjectCell( (String)null, class1[result[i][0]], class2[result[i][1]], BasicRelation.createRelation("="), val ) ); addCell( new ObjectCell( (String)null, class1[result[i][0]], class2[result[i][1]], BasicRelation.createRelation("="), val ) );
}
} }
} }
}
} catch (AlignmentException alex) { alex.printStackTrace(); } } catch (AlignmentException alex) { alex.printStackTrace(); }
catch (OntowrapException owex) { owex.printStackTrace(); } catch (OntowrapException owex) { owex.printStackTrace(); }
// For properties // For properties
......
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