Mentions légales du service

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

- clean up during documentation

parent 54b17c0b
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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.
*
*/
......
......@@ -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();
}
......
......@@ -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();
}
}
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