From f5af86d82d62dd8f99eb75c2420ddfd44216cabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Sun, 24 Mar 2013 17:42:41 +0000 Subject: [PATCH] - various adjustments and comments --- html/tutorial/tutorial4/index.html | 10 ++--- html/tutorial/tutorial4/results/myresult.owl | 45 ------------------- .../exmo/align/gen/alt/BasicAlterator.java | 1 + .../exmo/align/gen/alt/SuppressHierarchy.java | 7 +-- .../align/impl/eval/SemPRecEvaluator.java | 6 +-- 5 files changed, 12 insertions(+), 57 deletions(-) delete mode 100644 html/tutorial/tutorial4/results/myresult.owl diff --git a/html/tutorial/tutorial4/index.html b/html/tutorial/tutorial4/index.html index ad813bcc..15ce35c4 100644 --- a/html/tutorial/tutorial4/index.html +++ b/html/tutorial/tutorial4/index.html @@ -146,7 +146,6 @@ URI uri2 = null; String u1 = "file:ontology1.owl"; String u2 = "file:ontology2.owl"; String method = "fr.inrialpes.exmo.align.impl.method.StringDistAlignment"; -String tempOntoFileName = "results/myresult.owl"; Properties params = new BasicParameters(); try { uri1 = new URI( u1 ); @@ -234,9 +233,8 @@ This can be done with the alignment API support. <p>In fact everything is done in one step:</p> <div class="java"> // (Sol1) generate a merged ontology between the ontologies (OWLAxioms) -PrintWriter writer = null; -File merged = new File( tempOntoFileName ); -writer = new PrintWriter ( new FileWriter( merged, false ), true ); +File merged = File.createTempFile( "MyApp-results",".owl"); +PrintWriter writer = new PrintWriter ( new FileWriter( merged, false ), true ); AlignmentVisitor renderer = new OWLAxiomsRendererVisitor(writer); al.render(renderer); writer.flush(); @@ -280,7 +278,7 @@ ontologies instead of the merged one. // (Sol1) Use SPARQL to answer queries (at the data level) InputStream in = new FileInputStream( merged ); Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF,null); -model.read( in, "file:"+tempOntoFileName ); +model.read( in, "file:"+merged.getPath() ); in.close(); </div> <p>Query (please play by changing the query)</p> @@ -317,7 +315,7 @@ ResultSetFormatter.out(System.out, results, query); <div class="java"> OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); // Load the ontology -OWLOntology ontology = manager.loadOntology( IRI.create( "file:"+tempOntoFileName ) ); +OWLOntology ontology = manager.loadOntology( IRI.create( "file:"+merged.getPath() ) ); OWLReasoner reasoner = new Reasoner( ontology ); </div> <p>Get the instances of "Estudiantes":</p> diff --git a/html/tutorial/tutorial4/results/myresult.owl b/html/tutorial/tutorial4/results/myresult.owl deleted file mode 100644 index b2f03a13..00000000 --- a/html/tutorial/tutorial4/results/myresult.owl +++ /dev/null @@ -1,45 +0,0 @@ -<rdf:RDF - xmlns:owl="http://www.w3.org/2002/07/owl#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" - xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> - - <owl:Ontology rdf:about=""> - <rdfs:comment>Matched ontologies</rdfs:comment> - <rdfs:comment>Generated by fr.inrialpes.exmo.align.renderer.OWLAxiomsRendererVisitor</rdfs:comment> - <rdfs:comment>method: fr.inrialpes.exmo.align.impl.method.StringDistAlignment</rdfs:comment> - <owl:imports rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl"/> - <owl:imports rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl"/> - </owl:Ontology> - - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#supervisor"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#phd-advisor"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#city"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#city-of-study"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#affiliation"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#institution"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#topic"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#topics-of-interest"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#firstname"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#first-name"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#lastname"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#name"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#year"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#year-in-phd"/> - </owl:DatatypeProperty> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#gender"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#gender"/> - </owl:DatatypeProperty> - <owl:Class rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#Estudiante"> - <owl:equivalentClass rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#Student"/> - </owl:Class> - <owl:DatatypeProperty rdf:about="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology1.owl#country"> - <owl:equivalentProperty rdf:resource="http://alignapi.gforge.inria.fr/tutorial/tutorial4/ontology2.owl#country-of-study"/> - </owl:DatatypeProperty> -</rdf:RDF> diff --git a/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java b/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java index c7a1f3b8..2475e307 100644 --- a/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java @@ -312,6 +312,7 @@ public abstract class BasicAlterator implements Alterator { } //check if the removed class appears as AllValueFrom or SomeValueFrom in a restriction + // JE2012: This should be replaced by all parentclasses @SuppressWarnings("unchecked") public void checkClassesRestrictions ( OntClass childClass, OntClass parentClass ) { String uri = childClass.getURI(); diff --git a/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java b/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java index e5c19935..e3ae8ea9 100755 --- a/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java +++ b/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java @@ -47,7 +47,7 @@ public class SuppressHierarchy extends BasicAlterator { }; // 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? + // JE: why not directly attach all classes to Thing (or the root) and set childs to all these classes but root to null? (JE2012: corrected) public void noHierarchy ( int level ) { if ( level == 1 ) return; ArrayList<OntClass> levelClasses = new ArrayList<OntClass>(); //the list of classes from that level @@ -62,8 +62,9 @@ public class SuppressHierarchy extends BasicAlterator { OntClass parentClass = parentLevelClasses.get( i ); //parent class //all the classes are subclasses of owl: Thing OntClass superClass = superLevelClasses.get( i ); //parent class of the child class parents - if ( superClass != null ) { //if ( !parentClass.getURI().equals( "Thing" ) ) { - childClass.addSuperClass( superClass ); + //if ( superClass != null ) childClass.addSuperClass( superClass ); + if ( !parentClass.getURI().equals( "Thing" ) ) { + childClass.removeSuperClass( parentClass ); } parentClass.removeSubClass( childClass ); } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java index 01bfb1e5..58f9281a 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java @@ -113,14 +113,14 @@ public class SemPRecEvaluator extends PRecEvaluator implements Evaluator { * @param al1 : the reference alignment * @param al2 : the alignment to evaluate **/ - public SemPRecEvaluator( Alignment al1, Alignment al2) throws AlignmentException { + public SemPRecEvaluator( Alignment al1, Alignment al2 ) throws AlignmentException { super( al1, al2 ); - logger.info( "Created a SemPREvaluator" ); + logger.debug( "Created a SemPREvaluator" ); convertToObjectAlignments( al1, al2 ); } public void init( Properties params ){ - super.init(); // ?? + super.init(); nbexpectedentailed = 0; nbfoundentailed = 0; // Set the semantics to be used -- GitLab