You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/09/27 21:40:46 UTC

svn commit: r1176557 - /incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java

Author: joern
Date: Tue Sep 27 19:40:45 2011
New Revision: 1176557

URL: http://svn.apache.org/viewvc?rev=1176557&view=rev
Log:
OPENNLP-235 Now also uses type to decide if to entities are equal.

Modified:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java?rev=1176557&r1=1176556&r2=1176557&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java Tue Sep 27 19:40:45 2011
@@ -109,6 +109,8 @@ public class Entity implements IAdaptabl
     return entityText;
   }
 
+  // Note: equals and hashCode should ignore confirm status, confidence
+  
   @Override
   public boolean equals(Object obj) {
     if (obj == this) {
@@ -116,7 +118,9 @@ public class Entity implements IAdaptabl
     }
     else if (obj instanceof Entity) {
       Entity entity = (Entity) obj;
-      return entity.getBeginIndex() == getBeginIndex() && entity.getEndIndex() == getEndIndex();
+      return entity.getBeginIndex() == getBeginIndex() &&
+          entity.getEndIndex() == getEndIndex() && 
+          entity.getType().equals(type);
     }
     else {
       return false;
@@ -125,7 +129,7 @@ public class Entity implements IAdaptabl
   
   @Override
   public int hashCode() {
-    return getBeginIndex() + getEndIndex();
+    return getBeginIndex() + getEndIndex() + type.hashCode();
   }
   
   public Object getAdapter(Class adapter) {