diff --git a/src/fr/inrialpes/exmo/align/cli/WGroupEval.java b/src/fr/inrialpes/exmo/align/cli/WGroupEval.java index 97c8bba4fd8f9e5db75540d2eddc4c5e6b10e5be..2e876956b85fb221292288e92aae48fd0fc85f79 100644 --- a/src/fr/inrialpes/exmo/align/cli/WGroupEval.java +++ b/src/fr/inrialpes/exmo/align/cli/WGroupEval.java @@ -342,8 +342,8 @@ public class WGroupEval { System.out.println("% Plots"); int k = 0; for ( String m: listAlgo ) { - double precision = (double)correctVect[k]/foundVect[k]; - double recall = (double)correctVect[k]/expected; + double precision = correctVect[k]/foundVect[k]; + double recall = correctVect[k]/expected; double prec2 = precision*precision; double a = ((prec2-(recall*recall)+1)/2); double b = java.lang.Math.sqrt( prec2 - (a*a) ); diff --git a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java index 8d91c1bd299d484ff5183b49e1b970c5137a95c8..961cbc2f0f6b6d4580b95f1a7dc9045911f2cbd0 100644 --- a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java +++ b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java @@ -32,6 +32,7 @@ import com.hp.hpl.jena.ontology.Restriction; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.shared.PrefixMapping; import com.hp.hpl.jena.vocabulary.OWL; +import com.hp.hpl.jena.rdf.model.AnonId; //Java import java.util.List; @@ -44,7 +45,7 @@ import java.util.Iterator; public class ClassHierarchy { private URITree root; //the root of the tree - private Map m_anonIDs = new HashMap(); + private Map<AnonId,String> m_anonIDs = new HashMap<AnonId,String>(); private int m_anonCount = 0; public ClassHierarchy() {} @@ -60,7 +61,7 @@ public class ClassHierarchy { } public void addClass( String childURI, String parentURI ) { - root.add( root, parentURI, childURI ); //we add the new childURI to the hierarchy + root.add( parentURI, childURI ); //we add the new childURI to the hierarchy } //updates the class hierarchy @@ -71,17 +72,12 @@ public class ClassHierarchy { //returns the list of classes from level level public List<OntClass> getClassesFromLevel( OntModel model, int level ) { ArrayList<OntClass> classes = new ArrayList<OntClass>(); - for ( URITree node : getNodesFromLevel(level) ) { + for ( URITree node : root.getNodesFromLevel( level ) ) { classes.add( model.getOntClass( node.getURI() ) ); //builds the list of classes } return classes; } - //get the nodes from a specific level - public List<URITree> getNodesFromLevel( int level ) { - return root.getNodesFromLevel( root, level); - } - //remove the URI of the class from the hierarchy //returns the parent of the class if it exists or 0 other way -> not owl:Thing public OntClass removeClass ( OntModel model, OntClass cls ) { @@ -102,7 +98,7 @@ public class ClassHierarchy { //return a random class from the level - level public OntClass getRandomClassFromLevel( OntModel model, int level ) { Random rdm = new Random(); - List<URITree> childrenNodes = getNodesFromLevel( level ); //get the list of nodes from the level level + List<URITree> childrenNodes = root.getNodesFromLevel( level ); //get the list of nodes from the level level int index = rdm.nextInt( childrenNodes.size() ); //get a random number between 0 and the number_of_classes_from_that_level return model.getOntClass( childrenNodes.get(index).getURI() ); //returns the class from the position that we have selected -> the random number } @@ -110,7 +106,7 @@ public class ClassHierarchy { //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 = getNodesFromLevel( level ); + List<URITree> childrenNodes = root.getNodesFromLevel( level ); for ( URITree childNode : childrenNodes ) { //for each child class URITree parentNode = childNode.getParent(); //get the parent node URITree superNode = parentNode.getParent(); //get the parents of the parent node @@ -151,11 +147,10 @@ public class ClassHierarchy { superNode.getChildrenList().remove( parentNode ); //remove it from the children list of parentNode } //flattenHierarchy( childrenNodes ); //modify the links among the nodes from the class hierarchy - root.changeDepth ( root, level ); //change the depth + root.changeDepth( level ); //change the depth } //builds the class hierarchy - @SuppressWarnings("unchecked") public void buildClassHierarchy(OntModel model) { Iterator i = model.listHierarchyRootClasses(); root = new URITree( "Thing" ); //the root of the hierarchy is always owl:Thing @@ -180,12 +175,12 @@ public class ClassHierarchy { } } - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // JE: Strange unchecked certainly fixable public void getClass ( OntClass cls, List occurs, int depth ) { renderClassDescription( cls, depth ); - if ( cls.canAs( OntClass.class ) && !occurs.contains( cls ) ) { // recurse to the next level down - for ( Iterator it = cls.listSubClasses( true ); it.hasNext(); ) { + if ( cls.canAs( OntClass.class ) && !occurs.contains( cls ) ) { // recurse to the next level down + for ( Iterator it = cls.listSubClasses( true ); it.hasNext(); ) { OntClass sub = (OntClass)it.next(); occurs.add( cls ); // we push this expression on the occurs list before we recurse getClass( sub, occurs, depth + 1 ); @@ -200,15 +195,14 @@ public class ClassHierarchy { public void printClassHierarchy() { System.out.println( "[--------------------]" ); System.out.println( "The class hierarchy" ); - root.printURITree( root ); //we print the tree + root.printURITree(); //we print the tree System.out.println( "The class hierachy" ); System.out.println( "[---------------------]" ); } - @SuppressWarnings("unchecked") public void renderClassDescription( OntClass c, int depth ) { if (c.isRestriction()) { - renderRestriction( (Restriction) c.as( Restriction.class ) ); + renderRestriction( c.as( Restriction.class ) ); } else { if ( !c.isAnon() ) { @@ -226,14 +220,14 @@ public class ClassHierarchy { //it the superclass is .../#Thing if ( parentURI.contains( "Thing" ) ) - root.add( root, uri, "Thing"); + root.add( uri, "Thing"); else - root.add( root, uri, parentURI); + root.add( uri, parentURI); } } if ( found == 0 ) //has no parent until now - root.add( root, uri, "Thing"); + root.add( uri, "Thing"); } else { renderAnonymous( c, "class" ); //an anonymous class } @@ -256,21 +250,12 @@ public class ClassHierarchy { } // Render an anonymous class or restriction - @SuppressWarnings("unchecked") protected void renderAnonymous( Resource anon, String name ) { - String anonID = (String) m_anonIDs.get( anon.getId() ); + String anonID = m_anonIDs.get( anon.getId() ); if (anonID == null) { anonID = "a-" + m_anonCount++; m_anonIDs.put( anon.getId(), anonID ); } } - - // Generate the indentation - protected void indent( int depth ) { - for (int i = 0; i < depth; i++) { - System.out.print( " " ); - } - } - } diff --git a/src/fr/inrialpes/exmo/align/gen/URITree.java b/src/fr/inrialpes/exmo/align/gen/URITree.java index 6a52937f4655ef2766c74e29f5e12108ed46519e..fdb77700fda0a6771e23a2fcdf6c2a3b031a6f33 100644 --- a/src/fr/inrialpes/exmo/align/gen/URITree.java +++ b/src/fr/inrialpes/exmo/align/gen/URITree.java @@ -97,19 +97,32 @@ public class URITree { } //add the node with the childURI to the parent with the URI parentURI - public void add( URITree root, String childURI, String parentURI ) { + public void add( String childURI, String parentURI ) { //adds the node to the class hierarchy -> a class might have more than one //superclass we have to add it to each superclass in part, not only to one - _addChildToNode( root, parentURI, childURI ); + _addChildToNode( this, parentURI, childURI ); + } + + //returns the URITree with the given URI + public void _addChildToNode( URITree root, String parentURI, String childURI) { + if ( getURI().equals( parentURI ) ) { //if the root has the URI as the URI searched + addChild( root, this, childURI ); //then add the child + } else { + for( URITree node : getChildrenList() ) { //we start to search recursively + node._addChildToNode( root, parentURI, childURI ); + } + } } //add a child + // JE: could have a better interface (and implementation, this public void addChild( URITree root, URITree node, String URI ) { // If already child, forget it for ( URITree n : node.getChildrenList() ) { if ( n.getURI().equals( URI ) ) return; } - // If already existing, suppress it + // If already existing, suppress it + // JE: Why at first level only? URITree toRemove = null; for ( URITree n : root.getChildrenList() ) { if ( n.getURI().equals( URI ) ) { @@ -119,17 +132,17 @@ public class URITree { } root.getChildrenList().remove( toRemove ); // Now, go and create it - addChildToNode( node, URI ); + node.addChildToNode( URI ); } //add child to a specific node - public void addChildToNode( URITree node, String URI ) { + public void addChildToNode( String URI ) { URITree child = new URITree( URI ); //creates a new node - child.setDepth( node.getDepth()+1 ); //set the depth of the node - if ( maxDepth < node.getDepth()+1 ) //keeps track of the max depth of the hierarchy - maxDepth = node.getDepth()+1; - child.setParent( node ); //sets the parent of the node - node.getChildrenList().add( child ); //adds the node to the parent children list + child.setDepth( getDepth()+1 ); //set the depth of the node + if ( maxDepth < getDepth()+1 ) //keeps track of the max depth of the hierarchy + maxDepth = getDepth()+1; + child.setParent( this ); //sets the parent of the node + getChildrenList().add( child ); //adds the node to the parent children list } //renames the class from the tree after we have renamed the classes @@ -137,7 +150,6 @@ public class URITree { rename( alignment, (String)alignment.get( "##" ) ); } - @SuppressWarnings("unchecked") public void rename( Properties alignment, String ns ) { String key = BasicAlterator.getLocalName( getURI() ); String val = (String)alignment.get( key ); @@ -148,42 +160,6 @@ public class URITree { } //returns the URITree with the given URI - @SuppressWarnings("unchecked") - public void _addChildToNode(URITree root, String parentURI, String childURI) { - if ( root.getURI().equals( parentURI ) ) { //if the root has the URI as the URI searched - //addChildToNode(root, URI); - addChild ( root, root, childURI ); //then add the child - return; - } else { - for( URITree node : root.getChildrenList() ) { //we start to search recursively - if ( node.getURI().equals( parentURI ) ) { - //addChildToNode(root.getChildAt(index), URI); //we found the node with the given URI, then we add the child - addChild( root, node, childURI ); - } - _addChild( root, node, 0, parentURI, childURI ); - } - } - } - - @SuppressWarnings("unchecked") - public void _addChild(URITree root, URITree node, int depth, String parentURI, String childURI) { - int index = 0; - URITree ans = null; - //verify if the label of the URITree is the one with the label of the URITree we search for - if ( node.getURI().equals( parentURI ) ) { - //addChildToNode(node, URI); //has found the parent - addChild (root, node, childURI); - } - - while( index < node.getChildrenSize()) { - URITree n = node.getChildAt( index ); - _addChild( root, n, depth+1, parentURI, childURI ); - index++; - } - } - - //returns the URITree with the given URI - @SuppressWarnings("unchecked") public URITree searchURITree( String URI ) { if ( getURI().equals( URI ) ) return this; //if the root has the URI as the URI searched for ( URITree node : getChildrenList() ) { //we start to search recursively @@ -193,136 +169,53 @@ public class URITree { return null; } - // JE: commented because never used - /* - //remove a child from the tree - @SuppressWarnings("unchecked") - public void removeFromURITree( URITree root, String URI ) { - int index = 0; - int found = 0; - - while ( index < root.getChildrenSize() ) { - if ( root.getChildAt( index ).getURI().equals( URI ) ) { - root.getChildrenList().remove( index ); //found the node to delete - //return; - } - - remove(root.getChildAt( index ), 0, URI); - index++; - } - } - - @SuppressWarnings("unchecked") - public void remove( URITree node, int depth, String URI) { - int index = 0; - int found = 0; - - if ( node.getURI().equals( URI ) ) { - URITree parent = node.getParent(); - //add the node children to the parent of the node - int cnt = 0; //reestablish the connection between nodes - while ( cnt < node.getChildrenSize() ) { - URITree child = node.getChildrenList().get( cnt ); - child.setDepth( node.getDepth() ); //modify the depth - child.setParent( parent ); //modify the parent - parent.getChildrenList().add( child ); //add the child to the parent of node - cnt++; - } - parent.getChildrenList().remove( node ); //remove the node from the children list - } - - while( index < node.getChildrenSize()) { - URITree n = node.getChildAt( index ); - remove( n, depth+1, URI ); - index++; - } - - } - */ //get all the node from a specific level - @SuppressWarnings("unchecked") - public List<URITree> getNodesFromLevel (URITree root, int level) { + public List<URITree> getNodesFromLevel( int level ) { List<URITree> nodes = new ArrayList<URITree>(); //to store the nodes from a specific level - int index = 0; - if ( root.getDepth() == level ) - nodes.add( root ); - while ( index < root.getChildrenList().size() ) { - getNodes ( root.getChildAt(index), 0, nodes, level );//recursively print all the children URITrees - index++; - } + getNodes( nodes, level ); //recursively print all the children URITrees return nodes; //return the list of nodes } - @SuppressWarnings("unchecked") - public void getNodes (URITree node, int depth, List<URITree> nodes, int level) { - int index = 0; - if ( node.getDepth() == level ) //if it's on the level that we want, we add it to the hierarchy - nodes.add( node ); - - while( index < node.getChildrenList().size() ) { - URITree n = node.getChildrenList().get(index); - getNodes( n, depth+1, nodes, level ); - index++; - } + public void getNodes ( List<URITree> nodes, int level) { + if ( getDepth() == level ) { //if it's on the level that we want, we add it to the hierarchy + nodes.add( this ); + } else { + for( URITree n : getChildrenList() ) { + n.getNodes( nodes, level ); //recursively print all the children URITrees + } + } } //change the depth if the nodes lower the level to node.getDepth()-1 - @SuppressWarnings("unchecked") - public void changeDepth( URITree root, int level ) { - int index = 0; + public void changeDepth( int level ) { maxDepth--; - while ( index < root.getChildrenList().size() ) { - change ( root.getChildAt(index), 0, level ); - index++; - } + change( level ); } - @SuppressWarnings("unchecked") - public void change (URITree node, int depth, int level) { - int index = 0; - - if ( node.getDepth() > level ) { //if it's on the level that we want, we add it to the hierarchy - int dept = node.getDepth(); - node.setDepth( dept-1 ); + public void change( int level ) { + if ( getDepth() > level ) { //if it's on the level that we want, we add it to the hierarchy + setDepth( getDepth()-1 ); } - - while( index < node.getChildrenList().size() ) { - URITree n = node.getChildrenList().get(index); - change( n, depth+1, level ); - index++; + for ( URITree n : getChildrenList() ) { + n.change( level ); } } //print the tree - @SuppressWarnings("unchecked") - public void printURITree( URITree root ) { - int index = 0; - //System.err.println( "[" + root.getURI() + "]" + "->" + root.getDepth() ); - - while ( index < root.getChildrenList().size() ) { - //recursively print all the children URITrees - print(root.getChildAt(index), 0); - index++; - } + public void printURITree() { + print( 0 ); } - @SuppressWarnings("unchecked") - public void print (URITree node, int depth) { - int index = 0; - indent( node.getDepth() ); - //System.err.println( "[" + node.getURI() + "]" + "->" + node.getDepth() ); - - while( index < node.getChildrenList().size() ) { - URITree n = node.getChildrenList().get( index ); - print( n, depth+1 ); - index++; - } + public void print( int depth ) { + indent( getDepth() ); + System.err.println( "[" + getURI() + "]" + "->" + getDepth() ); + for( URITree n : getChildrenList() ) { + n.print( depth+1 ); + } } protected void indent( int depth ) { - for (int i = 0; i < depth; i++) { - System.out.print( " " ); - } + for ( int i = 0; i < depth; i++ ) System.out.print( " " ); } } diff --git a/src/fr/inrialpes/exmo/align/impl/BasicRelation.java b/src/fr/inrialpes/exmo/align/impl/BasicRelation.java index 2cb06d950109884f54b5b6346a9cc0f017df4f99..1370d674819793a72404ba3100da1203f9dd6247 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicRelation.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2005, 2007, 2009-2011 + * Copyright (C) INRIA, 2003-2005, 2007, 2009-2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by diff --git a/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java b/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java index f11dce0bcacaedfca6534115ee67e90c07d42ac8..72fd167ae6c58145f605840e8effed235dace60d 100644 --- a/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java +++ b/src/fr/inrialpes/exmo/align/impl/InstanceBasedMatrixMeasure.java @@ -67,15 +67,17 @@ public abstract class InstanceBasedMatrixMeasure extends MatrixMeasure { similarity = false; // This is a distance }; - public void initialize( LoadedOntology onto1, LoadedOntology onto2, Alignment align ) { + + @SuppressWarnings({"unchecked"}) + public void initialize( LoadedOntology onto1, LoadedOntology onto2, Alignment align ) { // create the matrices and all structures super.initialize( onto1, onto2, align ); try { if ( !(onto1 instanceof HeavyLoadedOntology) || !(onto2 instanceof HeavyLoadedOntology) ) throw new AlignmentException( "InstanceBasedMatrixMeasure requires HeavyLoadedOntology"); - HeavyLoadedOntology ontology1 = (HeavyLoadedOntology)onto1; - HeavyLoadedOntology ontology2 = (HeavyLoadedOntology)onto2; + HeavyLoadedOntology ontology1 = (HeavyLoadedOntology)onto1; + HeavyLoadedOntology ontology2 = (HeavyLoadedOntology)onto2; // Normalise class comparators (which instance belongs to which class) classinst1 = new Set[nbclass1]; diff --git a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java index 0cb5e2c62fa6cf43c62bbe36e44f29599ae07da9..473aedc384e4beff851b1ce48f064ec1a681b01e 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/ExtPREvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2004-2010 + * Copyright (C) INRIA, 2004-2010, 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -153,7 +153,7 @@ public class ExtPREvaluator extends BasicEvaluator implements Evaluator { nbfound = align2.nbCells(); for ( Cell c1 : align1 ){ - Set<Cell> s2 = (Set<Cell>)align2.getAlignCells1( c1.getObject1() ); + Set<Cell> s2 = align2.getAlignCells1( c1.getObject1() ); try { URI uri1 = onto2.getEntityURI( c1.getObject2() ); if( s2 != null ){ diff --git a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java index 25463e30248946b78e8ceb3def555f9266081699..1fff7bc05da1cf6f47639b3e98cede9a348c6d09 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/WeightedPREvaluator.java @@ -1,7 +1,7 @@ /* * $Id: WeightedPRecEvaluator.java 1494 2010-07-23 14:43:36Z euzenat $ * - * Copyright (C) INRIA, 2004-2011 + * Copyright (C) INRIA, 2004-2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -130,8 +130,8 @@ public class WeightedPREvaluator extends BasicEvaluator implements Evaluator { // nbexpected is 0 [=> nbcorrect is 0] (r=1, p=0) // precision+recall is 0 [= nbcorrect is 0] // precision is 0 [= nbcorrect is 0] - if ( nbfound != 0 ) precision = (double) nbcorrect / (double) nbfound; - if ( nbexpected != 0 ) recall = (double) nbcorrect / (double) nbexpected; + if ( nbfound != 0 ) precision = nbcorrect / nbfound; + if ( nbexpected != 0 ) recall = nbcorrect / nbexpected; return computeDerived(); } public double eval( Properties params, Object cache ) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java b/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java index de47756f059e8ecdae9c24a414f8b4574615a338..c0b936e7ac05f5011903f13dfdc66aa54b7e82f8 100644 --- a/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/HeavyLoadedOntology.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008, 2010 + * Copyright (C) INRIA, 2008, 2010, 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -35,7 +35,7 @@ public interface HeavyLoadedOntology<O> extends LoadedOntology<O> { public boolean getCapabilities( int Direct, int Asserted, int Named ) throws OntowrapException; /* Class methods */ - public <E >Set<E> getSubClasses( E c, int local, int asserted, int named ); + public Set<? extends Object> getSubClasses( Object c, int local, int asserted, int named ); public Set<? extends Object> getSuperClasses( Object c, int local, int asserted, int named ) throws OntowrapException; public Set<? extends Object> getProperties( Object c, int local, int asserted, int named ) throws OntowrapException; public Set<? extends Object> getDataProperties( Object c, int local, int asserted, int named ) throws OntowrapException; diff --git a/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java b/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java index 7ecda0acc88e564a7b75ec15f7ba5a8168bcc916..abf90c7aa471d00aae69ef729e32945742de3d0c 100644 --- a/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java +++ b/src/fr/inrialpes/exmo/ontowrap/jena25/JENAOntology.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2008, 2010 + * Copyright (C) INRIA, 2003-2008, 2010, 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -315,8 +315,8 @@ public class JENAOntology extends BasicOntology<OntModel> implements HeavyLoaded public Set<OntProperty> getObjectProperties(Object c, int local, int asserted, int named) { return new EntityFilter<OntProperty>( ((OntClass) c).listDeclaredProperties(asserted==OntologyFactory.DIRECT).toSet(),this) { - protected boolean isFiltered(OntProperty obj) { - return super.isFiltered(obj) && !((OntProperty) obj).isObjectProperty(); + protected boolean isFiltered( OntProperty obj ) { + return super.isFiltered(obj) && !obj.isObjectProperty(); } }; } @@ -328,7 +328,7 @@ public class JENAOntology extends BasicOntology<OntModel> implements HeavyLoaded return ((OntProperty) p).listRange().toSet(); } - public Set<? extends Object> getSubClasses(Object c, int local, int asserted, int named) { + public Set<? extends OntClass> getSubClasses(Object c, int local, int asserted, int named) { return ((OntClass) c).listSubClasses(asserted==OntologyFactory.DIRECT).toSet(); } diff --git a/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java b/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java index 525d28ac2bbb56fba5f17cff1d21c826d5b48606..d0fbea57fdda2742bf8a342eef77be828e2d66ea 100644 --- a/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java +++ b/src/fr/inrialpes/exmo/ontowrap/skosapi/SKOSThesaurus.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2009-2010 + * Copyright (C) INRIA, 2009-2010, 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -48,10 +48,10 @@ public class SKOSThesaurus extends BasicOntology<SKOSDataset> implements HeavyLo SKOSDataFactory factory; - private static HashSet NullSet = new HashSet(); + private static HashSet<Object> NullSet = new HashSet<Object>(); public SKOSThesaurus () { - NullSet = new HashSet(); + NullSet = new HashSet<Object>(); } public void setFactory( SKOSDataFactory df ){ diff --git a/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java b/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java index c3e539f0826f7520b4891ccd1c8b43cf6d7ce6c1..51291e00c8df5d17369beda4e64f355069f2398b 100644 --- a/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java +++ b/src/fr/inrialpes/exmo/ontowrap/skoslite/SKOSLiteThesaurus.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2008-2010 + * Copyright (C) INRIA, 2008-2010, 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -148,24 +148,22 @@ public class SKOSLiteThesaurus implements HeavyLoadedOntology<Model> { * returns all sub concepts of given object c. * */ - @SuppressWarnings("unchecked") - public <E> Set<E> getSubClasses(E c, int local, int asserted, int named) { - HashSet<E> sub = new HashSet<E>(); + public Set<? extends Object> getSubClasses(Object c, int local, int asserted, int named) { + HashSet<Object> sub = new HashSet<Object>(); //System.out.println(c); StmtIterator it =ontoInf.listStatements(null,ontoInf.getProperty(SKOS_BROADERTRANSITIVE),(Resource) c); - while (it.hasNext()) { + while ( it.hasNext() ) { Statement st = it.next(); - sub.add((E)st.getSubject()); + sub.add( st.getSubject() ); } it =ontoInf.listStatements((Resource) c,ontoInf.getProperty(SKOS_NARROWERTRANSITIVE),(RDFNode)null); while (it.hasNext()) { Statement st = it.next(); - sub.add((E)st.getObject()); + sub.add( st.getObject() ); } return sub; } - @Override public Set<? extends Object> getSuperClasses(Object c, int local, int asserted, int named) throws OntowrapException { HashSet<Object> sub = new HashSet<Object>();