From 3c28ad34acafac8a695ff561294396da468643ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Fri, 30 Mar 2007 17:28:53 +0000 Subject: [PATCH] - corrected bug about creation of relations - generalized creation of standard relations with < and > - creation of standard relations from classname --- html/relnotes.html | 2 ++ .../exmo/align/impl/BasicAlignment.java | 2 +- .../exmo/align/impl/BasicRelation.java | 19 ++++++++++++++----- .../exmo/align/impl/rel/SubsumedRelation.java | 7 +++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/html/relnotes.html b/html/relnotes.html index 827bbcc0..57e572cb 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -29,11 +29,13 @@ <p><ul compact="1"> <li>Added a <tt>parseString( String )</tt> method in <tt>AlignmentParser</tt></li> +<li>Implemented parsing of relations named by class name</li> <li>Got rid of the property file for wordnet</li> <li>In Server/FIPA, suppressed generated files on close()</li> <li>In Server/FIPA, suppressed printout</li> <li>Completely rewritten autodetection of renderers and methods in server</li> <li>Corrected an error on "force"-ing alignment in Server/HTML (was inverted)</li> +<li>Corrected bugs in relation writing/parsing</li> <li>Transferred the TODOs to gforge</li> </ul></p> diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java index 5b83a606..9dfd99ba 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java @@ -207,7 +207,7 @@ public class BasicAlignment implements Alignment { // JE: Why does this not allow to create cells with ids preserved? // This would be useful when the Alignements are cloned to preserve them public Cell addAlignCell(Object ob1, Object ob2, String relation, double measure) throws AlignmentException { - return addAlignCell( (String)null, ob1, ob2, BasicRelation.createRelation("="), measure ); + return addAlignCell( (String)null, ob1, ob2, BasicRelation.createRelation(relation), measure ); }; public Cell addAlignCell(Object ob1, Object ob2) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/impl/BasicRelation.java b/src/fr/inrialpes/exmo/align/impl/BasicRelation.java index f90ffbeb..48d18b09 100644 --- a/src/fr/inrialpes/exmo/align/impl/BasicRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/BasicRelation.java @@ -22,6 +22,7 @@ package fr.inrialpes.exmo.align.impl; import fr.inrialpes.exmo.align.impl.rel.EquivRelation; import fr.inrialpes.exmo.align.impl.rel.SubsumeRelation; +import fr.inrialpes.exmo.align.impl.rel.SubsumedRelation; import fr.inrialpes.exmo.align.impl.rel.IncompatRelation; import fr.inrialpes.exmo.align.impl.rel.NonTransitiveImplicationRelation; @@ -29,6 +30,7 @@ import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.Relation; +import java.lang.reflect.Constructor; import java.io.PrintWriter; import org.xml.sax.ContentHandler; @@ -65,16 +67,23 @@ public class BasicRelation implements Relation Relation relation = null; if ( rel.equals("=") ) { relation = new EquivRelation(); - } else if ( rel.equals("<") ) { + } else if ( rel.equals("<") || rel.equals("<") ) { relation = new SubsumeRelation(); + } else if ( rel.equals(">") || rel.equals(">") ) { + relation = new SubsumedRelation(); } else if ( rel.equals("%") ) { relation = new IncompatRelation(); - } else if ( rel.equals("~>") ) { + } else if ( rel.equals("~>") || rel.equals("~>") ) { relation = new NonTransitiveImplicationRelation(); } else { - // I could use the class name for relation, - // this would be more extensible... - relation = new BasicRelation("="); + try { + // Create a relation from classname + Class relationClass = Class.forName(rel); + Constructor relationConstructor = relationClass.getConstructor((Class[])null); + relation = (Relation)relationConstructor.newInstance((Object[])null); + } catch ( Exception ex ) { + ex.printStackTrace(); + } }; return relation; } diff --git a/src/fr/inrialpes/exmo/align/impl/rel/SubsumedRelation.java b/src/fr/inrialpes/exmo/align/impl/rel/SubsumedRelation.java index 443cc40e..a90b79fd 100644 --- a/src/fr/inrialpes/exmo/align/impl/rel/SubsumedRelation.java +++ b/src/fr/inrialpes/exmo/align/impl/rel/SubsumedRelation.java @@ -24,6 +24,8 @@ import org.semanticweb.owl.align.AlignmentVisitor; import fr.inrialpes.exmo.align.impl.BasicRelation; +import java.io.PrintWriter; + /** * Represents an OWL subsumption relation. * @@ -45,6 +47,11 @@ public class SubsumedRelation extends BasicRelation public SubsumedRelation(){ super("<"); } + + public void write( PrintWriter writer ) { + writer.print("<"); + } + } -- GitLab