diff --git a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java index 961cbc2f0f6b6d4580b95f1a7dc9045911f2cbd0..5a57f0784e48f554b5f2b22bebc154734ebf344c 100644 --- a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java +++ b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java @@ -103,7 +103,6 @@ public class ClassHierarchy { return model.getOntClass( childrenNodes.get(index).getURI() ); //returns the class from the position that we have selected -> the random number } - //modifies the class hierarchy after we have flattened it public void flattenClassHierarchy( OntModel model, int level, ArrayList<OntClass> childClasses, ArrayList<OntClass> parentClasses, ArrayList<OntClass> superLevelClasses) { List<URITree> childrenNodes = root.getNodesFromLevel( level ); @@ -138,7 +137,7 @@ public class ClassHierarchy { } System.err.println(); */ - childNode.setParent( parentNode.getParent() ); //change the parent of my superclass to the [parent of the "parent node"] + childNode.setParent( superNode ); //change the parent of my superclass to the [parent of the "parent node"] // JE : likely wrong in multiple inheritance childNode.setDepth( parentNode.getDepth() ); //change it's depth parentNode.getChildrenList().remove( childNode ); //remove it from the children list of parentNode diff --git a/src/fr/inrialpes/exmo/align/gen/OntologyNetworkWeakener.java b/src/fr/inrialpes/exmo/align/gen/OntologyNetworkWeakener.java index d044fac1a1287e046fdbdc75a2abbd438c0d6411..8293adc282621108a61badca8996168886bf8872 100644 --- a/src/fr/inrialpes/exmo/align/gen/OntologyNetworkWeakener.java +++ b/src/fr/inrialpes/exmo/align/gen/OntologyNetworkWeakener.java @@ -30,7 +30,7 @@ import java.util.Properties; * OntologyNetworkWeakener * * A interface which alters ontology networks. - * NOTE: These two primitives would benefit from the hability to declare static in ineterfaces... + * NOTE: These two primitives would benefit from the hability to declare static in interfaces... * Now we have to create instances of the implementing classes. * */ diff --git a/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java index e0075602fbcc4f3dc220fe02ad4659ca750af44a..6e9116a9924c7f872cfe0810416071a4aa15853a 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java @@ -46,8 +46,7 @@ public class AddClassLevel extends BasicAlterator { int nbClasses = Integer.valueOf( p.substring(index+1, p.length()) ); if ( debug ) System.err.println( "level " + level ); if ( debug ) System.err.println( "nbClasses " + nbClasses ); - float percentage = 1.00f; - String classURI; + //float percentage = 1.00f; //the parent class -> if level is 1 then we create a new class //else we get a random class from the level : level-1 to be the parent of the class OntClass parentClass; @@ -57,28 +56,22 @@ public class AddClassLevel extends BasicAlterator { buildClassHierarchy(); //check if the class hierarchy is built if ( level == 1 ) { //the parent of the class is Thing, we add the class and then the rest of the classes - classURI = getRandomString(); - parentClass = modifiedModel.createClass( modifiedOntologyNS + classURI );//create a new class to the model - classHierarchy.addClass( modifiedOntologyNS + classURI, "Thing" ); //add the node in the hierarchy of classes - childClasses.add(parentClass); - } - else { - parentClasses = classHierarchy.getClassesFromLevel(modifiedModel, level); - int nbParentClasses = parentClasses.size(); //number of classes from the Ontology - int toAdd = Math.round( percentage*nbClasses ); // 1 can be replaced by percentage - + String classURI = getRandomString(); + parentClass = modifiedModel.createClass( modifiedOntologyNS + classURI );//create a new class to the model + classHierarchy.addClass( modifiedOntologyNS + classURI, "Thing" ); //add the node in the hierarchy of classes + childClasses.add(parentClass); + } else { + parentClasses = classHierarchy.getClassesFromLevel( modifiedModel, level ); + //int nbParentClasses = parentClasses.size(); //number of classes from the Ontology + //int toAdd = Math.round( percentage*nbClasses ); // 1 can be replaced by percentage for ( OntClass pClass : parentClasses ) { - classURI = getRandomString(); - childClass = addClass (pClass, classURI ); - pClass = childClass; - childClasses.add( childClass ); + childClasses.add( addClass( pClass, getRandomString() ) ); } } - for ( OntClass pClass : childClasses ) { - classURI = "IS_" + getLocalName( pClass.getURI() ); - for ( int i=level+1; i<level + nbClasses; i++ ) { - childClass = addClass (pClass, classURI); + String classURI = "IS_" + getLocalName( pClass.getURI() ); + for ( int i = 1; i < nbClasses; i++ ) { + childClass = addClass( pClass, classURI ); pClass = childClass; } //this.classHierarchy.printClassHierarchy(); } diff --git a/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java b/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java index 1f71b69d269217518a82a9439ffd947887810f2b..e5c1993569f0457679d379216bd5a08b47a26af0 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java @@ -39,16 +39,15 @@ public class SuppressHierarchy extends BasicAlterator { public Alterator modify( Properties params ) { String p = params.getProperty( ParametersIds.NO_HIERARCHY ); if ( p == null ) return null; - int level = getMaxLevel(); - while ( getMaxLevel() != 1 ) { // JE: dangerous to not use level - //this.classHierarchy.printClassHierarchy(); + buildClassHierarchy(); //builds the class hierarchy if necessary + for( int level = classHierarchy.getMaxLevel(); level > 1; level-- ) { noHierarchy ( level ); - level--; } return this; // useless }; - // flatten level + // This suppress attach all classes of a level to the level above + // JE: why not directly attach all classes to Thing (or the root) and set childs to all these classes but root to null? public void noHierarchy ( int level ) { if ( level == 1 ) return; ArrayList<OntClass> levelClasses = new ArrayList<OntClass>(); //the list of classes from that level @@ -69,11 +68,4 @@ public class SuppressHierarchy extends BasicAlterator { parentClass.removeSubClass( childClass ); } } - - //must have the max level of the class hierarchy - public int getMaxLevel() { - buildClassHierarchy(); //check if the class hierarchy is built - return classHierarchy.getMaxLevel(); - } - }