You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/12/18 10:04:55 UTC

svn commit: r1551886 - in /stanbol/trunk/enhancer/generic: nlp-json/src/test/java/org/apache/stanbol/enhancer/nlp/json/valuetype/CorefFeatureSupportTest.java nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java

Author: rwesten
Date: Wed Dec 18 09:04:55 2013
New Revision: 1551886

URL: http://svn.apache.org/r1551886
Log:
STANBOL-1132: forgott to commit patch changes to CorefFeatureSupportTest; Changed hashcode and equals implementation of DependencyRelation

Modified:
    stanbol/trunk/enhancer/generic/nlp-json/src/test/java/org/apache/stanbol/enhancer/nlp/json/valuetype/CorefFeatureSupportTest.java
    stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java

Modified: stanbol/trunk/enhancer/generic/nlp-json/src/test/java/org/apache/stanbol/enhancer/nlp/json/valuetype/CorefFeatureSupportTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp-json/src/test/java/org/apache/stanbol/enhancer/nlp/json/valuetype/CorefFeatureSupportTest.java?rev=1551886&r1=1551885&r2=1551886&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp-json/src/test/java/org/apache/stanbol/enhancer/nlp/json/valuetype/CorefFeatureSupportTest.java (original)
+++ stanbol/trunk/enhancer/generic/nlp-json/src/test/java/org/apache/stanbol/enhancer/nlp/json/valuetype/CorefFeatureSupportTest.java Wed Dec 18 09:04:55 2013
@@ -22,34 +22,34 @@ public class CorefFeatureSupportTest ext
 	private static final String sentenceText2 = " He met with the Chinese prime-minister.";
 	private static final String text = sentenceText1 + sentenceText2;
 	
-	private static final String jsonCorefCheckObama = "{\n"
-	    + "    \"type\" : \"Token\",\n"
-	    + "    \"start\" : 0,\n"
-	    + "    \"end\" : 5,\n"
-	    + "    \"stanbol.enhancer.nlp.coref\" : {\n"
-	    + "      \"isRepresentative\" : true,\n"
-	    + "      \"mentions\" : [ {\n"
-	    + "        \"type\" : \"Token\",\n"
-	    + "        \"start\" : 21,\n"
-	    + "        \"end\" : 23\n"
-	    + "      } ],\n"
-	    + "      \"class\" : \"org.apache.stanbol.enhancer.nlp.coref.CorefFeature\"\n"
-	    + "    }\n"
+	private static final String jsonCorefCheckObama = "{" + LINE_SEPARATOR
+	    + "    \"type\" : \"Token\"," + LINE_SEPARATOR
+	    + "    \"start\" : 0," + LINE_SEPARATOR
+	    + "    \"end\" : 5," + LINE_SEPARATOR
+	    + "    \"stanbol.enhancer.nlp.coref\" : {" + LINE_SEPARATOR
+	    + "      \"isRepresentative\" : true," + LINE_SEPARATOR
+	    + "      \"mentions\" : [ {" + LINE_SEPARATOR
+	    + "        \"type\" : \"Token\"," + LINE_SEPARATOR
+	    + "        \"start\" : 21," + LINE_SEPARATOR
+	    + "        \"end\" : 23" + LINE_SEPARATOR
+	    + "      } ]," + LINE_SEPARATOR
+	    + "      \"class\" : \"org.apache.stanbol.enhancer.nlp.coref.CorefFeature\"" + LINE_SEPARATOR
+	    + "    }" + LINE_SEPARATOR
 		+ "  }";
 	
-	private static final String jsonCorefCheckHe = "{\n"
-	    + "    \"type\" : \"Token\",\n"
-	    + "    \"start\" : 21,\n"
-	    + "    \"end\" : 23,\n"
-	    + "    \"stanbol.enhancer.nlp.coref\" : {\n"
-	    + "      \"isRepresentative\" : false,\n"
-	    + "      \"mentions\" : [ {\n"
-	    + "        \"type\" : \"Token\",\n"
-	    + "        \"start\" : 0,\n"
-	    + "        \"end\" : 5\n"
-	    + "      } ],\n"
-	    + "      \"class\" : \"org.apache.stanbol.enhancer.nlp.coref.CorefFeature\"\n"
-	    + "    }\n"
+	private static final String jsonCorefCheckHe = "{" + LINE_SEPARATOR
+	    + "    \"type\" : \"Token\"," + LINE_SEPARATOR
+	    + "    \"start\" : 21," + LINE_SEPARATOR
+	    + "    \"end\" : 23," + LINE_SEPARATOR
+	    + "    \"stanbol.enhancer.nlp.coref\" : {" + LINE_SEPARATOR
+	    + "      \"isRepresentative\" : false," + LINE_SEPARATOR
+	    + "      \"mentions\" : [ {" + LINE_SEPARATOR
+	    + "        \"type\" : \"Token\"," + LINE_SEPARATOR
+	    + "        \"start\" : 0," + LINE_SEPARATOR
+	    + "        \"end\" : 5" + LINE_SEPARATOR
+	    + "      } ]," + LINE_SEPARATOR
+	    + "      \"class\" : \"org.apache.stanbol.enhancer.nlp.coref.CorefFeature\"" + LINE_SEPARATOR
+	    + "    }" + LINE_SEPARATOR
 	    + "  }";
 	
 	@BeforeClass

Modified: stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java?rev=1551886&r1=1551885&r2=1551886&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java (original)
+++ stanbol/trunk/enhancer/generic/nlp/src/main/java/org/apache/stanbol/enhancer/nlp/dependency/DependencyRelation.java Wed Dec 18 09:04:55 2013
@@ -62,21 +62,38 @@ public class DependencyRelation {
 		return this.partner;
 	}
 
-	public int hashCode() {
-		return grammaticalRelationTag.hashCode()
-				+ ((partner != null) ? partner.hashCode() : 0)
-				+ +(isDependent ? 1 : 0);
-	}
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((grammaticalRelationTag == null) ? 0
+                        : grammaticalRelationTag.hashCode());
+        result = prime * result + (isDependent ? 1231 : 1237);
+        result = prime * result + ((partner == null) ? 0 : partner.hashCode());
+        return result;
+    }
 
-	public boolean equals(Object obj) {
-		return (obj instanceof DependencyRelation)
-				&& (this.grammaticalRelationTag
-						.equals(((DependencyRelation) obj)
-								.getGrammaticalRelationTag()))
-				&& (this.isDependent == ((DependencyRelation) obj)
-						.isDependent())
-				&& (this.partner == null
-						&& ((DependencyRelation) obj).getPartner() == null || this.partner
-							.equals(((DependencyRelation) obj).getPartner()));
-	}
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        DependencyRelation other = (DependencyRelation) obj;
+        if (grammaticalRelationTag == null) {
+            if (other.grammaticalRelationTag != null)
+                return false;
+        } else if (!grammaticalRelationTag.equals(other.grammaticalRelationTag))
+            return false;
+        if (isDependent != other.isDependent)
+            return false;
+        if (partner == null) {
+            if (other.partner != null)
+                return false;
+        } else if (!partner.equals(other.partner))
+            return false;
+        return true;
+    }
 }