From 0709c24bb374353c96d131cbf509faf1f5deac9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Thu, 8 Feb 2007 09:06:00 +0000
Subject: [PATCH] - added protection in case URI have no fragments

---
 .../exmo/align/ling/JWNLAlignment.java        | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java b/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java
index b4a80e98..e523b35c 100644
--- a/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java
+++ b/src/fr/inrialpes/exmo/align/ling/JWNLAlignment.java
@@ -34,6 +34,8 @@ import org.semanticweb.owl.align.AlignmentProcess;
 import org.semanticweb.owl.align.AlignmentException;
 import org.semanticweb.owl.align.Parameters;
 
+import java.net.URI;
+
 /**
  * This Class uses JWNLDistances to align two ontologies.
  * @author  Jerome Pierson
@@ -54,16 +56,29 @@ public class JWNLAlignment extends DistanceAlignment implements AlignmentProcess
 	public double measure( OWLClass cl1, OWLClass cl2 ) throws OWLException{
 	    String s1 = cl1.getURI().getFragment();
 	    String s2 = cl2.getURI().getFragment();
+	    if ( s1 == null || s2 == null ) return 1.;
 	    return Dist.BasicSynonymDistance(s1.toLowerCase(),s2.toLowerCase());
 	}
 	public double measure( OWLProperty pr1, OWLProperty pr2 ) throws OWLException{
 	    String s1 = pr1.getURI().getFragment();
 	    String s2 = pr2.getURI().getFragment();
+	    if ( s1 == null || s2 == null ) return 1.;
 	    return Dist.BasicSynonymDistance(s1.toLowerCase(),s2.toLowerCase());
 	}
 	public double measure( OWLIndividual id1, OWLIndividual id2 ) throws OWLException{
-	    String s1 = id1.getURI().getFragment();
-	    String s2 = id2.getURI().getFragment();
+	    if ( debug > 4 ) 
+			System.err.println( "ID:"+id1+" -- "+id2);
+	    URI URI1 = id1.getURI();
+	    String s1;
+	    if ( URI1 != null ) s1 = URI1.getFragment();
+	    else s1 = "";
+	    URI URI2 = id2.getURI();
+	    String s2;
+	    if ( URI2 != null ) s2 = URI2.getFragment();
+	    else s2 = "";
+	    if ( s1 == null || s2 == null ) return 1.;
+	    //	    String s1 = id1.getURI().getFragment();
+	    //		    String s2 = id2.getURI().getFragment();
 	    return Dist.BasicSynonymDistance(s1.toLowerCase(),s2.toLowerCase());
 	}
     }
-- 
GitLab