From 00ca8d624f54dc94a665be5154e3f8bcc70a2d5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Thu, 15 Jun 2006 07:39:33 +0000
Subject: [PATCH] - fixed the problem tied to the fact that OWL-APi returns
 indiviuals with (null) URI

---
 .../exmo/align/impl/MatrixMeasure.java         |  3 ++-
 .../align/impl/method/StringDistAlignment.java | 18 ++++++++++++++++--
 .../impl/renderer/RDFRendererVisitor.java      |  5 ++++-
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java b/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java
index 20de6aff..773fc59d 100644
--- a/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java
+++ b/src/fr/inrialpes/exmo/align/impl/MatrixMeasure.java
@@ -119,7 +119,7 @@ public abstract class MatrixMeasure implements Similarity {
 		indlist2.put( it.next(), new Integer(nbind2) );
 	    }
 	    for ( Iterator it = onto1.getIndividuals().iterator(); it.hasNext(); nbind1++ ){
-		indlist1.put( it.next(), new Integer(nbind1)  );
+		indlist1.put( it.next(), new Integer(nbind1) );
 	    }
 	    indmatrix = new double[nbind1+1][nbind2+1];
 
@@ -136,6 +136,7 @@ public abstract class MatrixMeasure implements Similarity {
 		    clmatrix[((Integer)classlist1.get(cl1)).intValue()][((Integer)classlist2.get(cl2)).intValue()] = measure( cl1, cl2 );
 		}
 	    }
+	    System.err.println("IND: "+nbind1+" / "+nbind2);
 	    // Compute distances on individuals
 	    // (this comes first because otherwise, it2 is defined)
 	    for ( Iterator it2 = onto2.getIndividuals().iterator(); it2.hasNext(); ){
diff --git a/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java b/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java
index 635f28ba..0a205280 100644
--- a/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java
+++ b/src/fr/inrialpes/exmo/align/impl/method/StringDistAlignment.java
@@ -23,6 +23,7 @@ package fr.inrialpes.exmo.align.impl.method;
 import java.util.Iterator;
 import java.util.Hashtable;
 import java.lang.reflect.Method;
+import java.net.URI;
 
 import org.semanticweb.owl.model.OWLOntology;
 import org.semanticweb.owl.model.OWLClass;
@@ -62,15 +63,28 @@ public class StringDistAlignment extends DistanceAlignment implements AlignmentP
 	setSimilarity( new MatrixMeasure() {
 		public double measure( OWLClass cl1, OWLClass cl2 ) throws Exception{
 		    String[] params = { cl1.getURI().getFragment(), cl2.getURI().getFragment() };
-		    //if ( debug > 4 ) 
+		    if ( debug > 4 ) 
+			System.err.println( "CL:"+cl1.getURI().getFragment()+" ++ "+cl2.getURI().getFragment());
 		    return ((Double)dissimilarity.invoke( null, params )).doubleValue();
 		}
 		public double measure( OWLProperty pr1, OWLProperty pr2 ) throws Exception{
 		    String[] params = { pr1.getURI().getFragment(), pr2.getURI().getFragment() };
+		    if ( debug > 4 ) 
+			System.err.println( "PR:"+pr1.getURI().getFragment()+" ++ "+pr2.getURI().getFragment());
 		    return ((Double)dissimilarity.invoke( null, params )).doubleValue();
 		}
 		public double measure( OWLIndividual id1, OWLIndividual id2 ) throws Exception{
-		    String[] params = { id1.getURI().getFragment(), id2.getURI().getFragment() };
+		    if ( debug > 4 ) 
+			System.err.println( "ID:"+id1+" -- "+id2);
+		    URI URI1 = id1.getURI();
+		    String name1;
+		    if ( URI1 != null ) name1 = URI1.getFragment();
+		    else name1 = "";
+		    URI URI2 = id2.getURI();
+		    String name2;
+		    if ( URI2 != null ) name2 = URI2.getFragment();
+		    else name2 = "";
+		    String[] params = { name1, name2 };
 		    return ((Double)dissimilarity.invoke( null, params )).doubleValue();
 		}
 	    } );
diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java
index c696a3d9..460c96e7 100644
--- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java
+++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) INRIA Rhône-Alpes, 2003-2005
+ * Copyright (C) INRIA Rhône-Alpes, 2003-2006
  *
  * 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
@@ -104,6 +104,8 @@ public class RDFRendererVisitor implements AlignmentVisitor
 	this.cell = cell;
 	//OWLOntology onto1 = (OWLOntology)alignment.getOntology1();
 	try {
+	    if ( ((OWLEntity)cell.getObject1()).getURI() != null &&
+		 ((OWLEntity)cell.getObject2()).getURI() != null ){
 	    writer.print("  <map>\n");
 	    writer.print("    <Cell");
 	    if ( cell.getId() != null ){
@@ -121,6 +123,7 @@ public class RDFRendererVisitor implements AlignmentVisitor
 	    writer.print("      <relation>");
 	    cell.getRelation().accept( this );
 	    writer.print("</relation>\n    </Cell>\n  </map>\n");
+	    }
 	} catch ( OWLException e) { throw new AlignmentException( "getURI problem", e ); }
     }
     public void visit( Relation rel ) {
-- 
GitLab