You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by ma...@apache.org on 2013/11/06 12:41:44 UTC

svn commit: r1539314 - in /opennlp/trunk/opennlp-tools: ./ src/main/java/opennlp/tools/entitylinker/ src/main/java/opennlp/tools/entitylinker/domain/

Author: markg
Date: Wed Nov  6 11:41:43 2013
New Revision: 1539314

URL: http://svn.apache.org/r1539314
Log:
OPENNLP-614
Removed all GeoEntityLinker impl specific classes from tools. Moved to the sandbox in a module called Apache Opennlp Addons

Removed:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/BaseEntityLinker.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/CountryContext.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/CountryContextEntry.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/CountryContextHit.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/CountryProximityScorer.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/FuzzyStringMatchScorer.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/GeoEntityLinker.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/GeoHashBinningScorer.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/LinkedEntityScorer.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/MySQLGeoNamesGazEntry.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/MySQLGeoNamesGazLinkable.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/MySQLUSGSGazEntry.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/MySQLUSGSGazLinkable.java
Modified:
    opennlp/trunk/opennlp-tools/pom.xml
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/BaseLink.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/LinkedSpan.java

Modified: opennlp/trunk/opennlp-tools/pom.xml
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/pom.xml?rev=1539314&r1=1539313&r2=1539314&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/pom.xml (original)
+++ opennlp/trunk/opennlp-tools/pom.xml Wed Nov  6 11:41:43 2013
@@ -20,135 +20,136 @@
 -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
 	
-	<parent>
-	    <groupId>org.apache.opennlp</groupId>
-	    <artifactId>opennlp</artifactId>
-	    <version>1.6.0-SNAPSHOT</version>
-	    <relativePath>../opennlp/pom.xml</relativePath>
-    </parent>
+  <parent>
+    <groupId>org.apache.opennlp</groupId>
+    <artifactId>opennlp</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+    <relativePath>../opennlp/pom.xml</relativePath>
+  </parent>
     
-	<artifactId>opennlp-tools</artifactId>
-	<packaging>bundle</packaging>
-	<name>Apache OpenNLP Tools</name>
+  <artifactId>opennlp-tools</artifactId>
+  <packaging>bundle</packaging>
+  <name>Apache OpenNLP Tools</name>
 
-	<dependencies>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <version>4.2.0</version>
-            <scope>provided</scope>
-            <optional>true</optional>
-        </dependency>
+  <dependencies>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>4.2.0</version>
+      <scope>provided</scope>
+      <optional>true</optional>
+    </dependency>
         
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <version>4.2.0</version>
-            <scope>provided</scope>
-            <optional>true</optional>
-        </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>4.2.0</version>
+      <scope>provided</scope>
+      <optional>true</optional>
+    </dependency>
         
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-        </dependency>
-	</dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
 
-	<build>
-		<resources>
-		    <resource>
-		      <directory>src/main/resources</directory>
-		      <filtering>true</filtering>
-		    </resource>
-		</resources>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<configuration>
-					<argLine>-Xmx512m</argLine>
-				</configuration>
-			</plugin>
+  </dependencies>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <argLine>-Xmx512m</argLine>
+        </configuration>
+      </plugin>
 			
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <version>2.3.1</version>
-                <configuration>
-                   <archive>
-                       <manifest>
-                           <addClasspath>true</addClasspath>
-                           <mainClass>opennlp.tools.cmdline.CLI</mainClass>
-                       </manifest>
-                   </archive>
-                </configuration>
-            </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.3.1</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <addClasspath>true</addClasspath>
+              <mainClass>opennlp.tools.cmdline.CLI</mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
             
-            <plugin>
-				<artifactId>maven-javadoc-plugin</artifactId>
-				<executions>
-					<execution>
-						<id>create-javadoc-jar</id>
-						<configuration>
-							<excludePackageNames>opennlp.tools.cmdline</excludePackageNames>
-						</configuration>
-					</execution>
-				</executions>
-			</plugin>
+      <plugin>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>create-javadoc-jar</id>
+            <configuration>
+              <excludePackageNames>opennlp.tools.cmdline</excludePackageNames>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
 			
-			<plugin>
-				<groupId>org.apache.felix</groupId>
-				<artifactId>maven-bundle-plugin</artifactId>
-				<extensions>true</extensions>
-				<configuration>
-					<instructions>
-						<Bundle-Activator>opennlp.tools.util.ext.OSGiExtensionLoader</Bundle-Activator>
-						<Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
-						<Export-Package>
-							!opennlp.tools.cmdline.*,
-							opennlp.tools.*
-						</Export-Package>
-						<Import-Package>*</Import-Package>
-					</instructions>
-				</configuration>
-			</plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-Activator>opennlp.tools.util.ext.OSGiExtensionLoader</Bundle-Activator>
+            <Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
+            <Export-Package>
+              !opennlp.tools.cmdline.*,
+              opennlp.tools.*
+            </Export-Package>
+            <Import-Package>*</Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
 			
-            <plugin>
-	        <groupId>org.apache.rat</groupId>
-	        <artifactId>apache-rat-plugin</artifactId>
-	        <executions>
-	          <execution>
-	            <id>default-cli</id>
-	            <configuration>
-	              <excludes>
-	                <exclude>src/test/resources/opennlp/tools/chunker/*.txt</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/formats/*.sample</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/namefind/*.txt</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/namefind/*.train</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/parser/en_head_rules</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/parser/en_head_rules</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/parser/parser.train</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/parser/test.parse</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/postag/AnnotatedSentences.txt</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/sentdetect/Sentences.txt</exclude> <!-- test data -->
-	                <exclude>src/test/resources/opennlp/tools/tokenize/token.train</exclude> <!-- test data -->
-	                <exclude>lang/en/parser/en-head_rules</exclude> <!-- head rule file, format does not allow AL header -->
-	              </excludes>              
-	            </configuration>
-	          </execution>
-	        </executions>
-	      </plugin>
-		 <plugin>
-		  <groupId>org.apache.maven.plugins</groupId>
-		  <artifactId>maven-compiler-plugin</artifactId>
-		  <version>2.3.2</version>
-		  <configuration>
-		   <source>1.7</source>
-		   <target>1.7</target>
-		  </configuration>
-		 </plugin>
-		</plugins>
-	</build>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>default-cli</id>
+            <configuration>
+              <excludes>
+                <exclude>src/test/resources/opennlp/tools/chunker/*.txt</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/formats/*.sample</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/namefind/*.txt</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/namefind/*.train</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/parser/en_head_rules</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/parser/en_head_rules</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/parser/parser.train</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/parser/test.parse</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/postag/AnnotatedSentences.txt</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/sentdetect/Sentences.txt</exclude> <!-- test data -->
+                <exclude>src/test/resources/opennlp/tools/tokenize/token.train</exclude> <!-- test data -->
+                <exclude>lang/en/parser/en-head_rules</exclude> <!-- head rule file, format does not allow AL header -->
+              </excludes>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.2</version>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java?rev=1539314&r1=1539313&r2=1539314&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java Wed Nov  6 11:41:43 2013
@@ -26,7 +26,8 @@ import opennlp.tools.util.Span;
  * Intended to return n best matches for any give search, but can also be
  * implemented as deterministic
  *
- * @param <T> A type that extends Span
+ * @param <T> A type that extends Span. LinkedSpan and BaseLink are provided to provide this signature:
+ * EntityLinker<LinkedSpan<BaseLink>> as a default
  *
  */
 public interface EntityLinker<T extends Span> {

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java?rev=1539314&r1=1539313&r2=1539314&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java Wed Nov  6 11:41:43 2013
@@ -15,12 +15,6 @@
  */
 package opennlp.tools.entitylinker;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 /**
  * Generates Lists of EntityLinker implementations via properties file
  * configuration
@@ -29,7 +23,7 @@ import java.util.logging.Logger;
 public class EntityLinkerFactory {
 
   /**
-   * instantiates a single linker based on properties file configuration. The properties file supports multiple types.
+   * instantiates a single linker based on properties file configuration.
    * @param entityType the type of entity, i.e. person, organization, location
    * @param properties the properties file that holds the configuration for entitylinkers.
    * @return
@@ -40,98 +34,16 @@ public class EntityLinkerFactory {
     }
     EntityLinker linker = null;
     try {
-      String linkerImplFullName = properties.getProperty("linker." + entityType, GeoEntityLinker.class.getName());
+      String linkerImplFullName = properties.getProperty("linker." + entityType,"");
       Class theClass = Class.forName(linkerImplFullName);
       linker = (EntityLinker) theClass.newInstance();
       System.out.println("EntityLinker factory instantiated: " + linker.getClass().getName());
       linker.setEntityLinkerProperties(properties);
 
-    } catch (InstantiationException ex) {
-      System.out.println("Check the entity linker properties file. The entry must be formatted as linker.<type>=<fullclassname>, i.e linker.person=org.my.company.MyPersonLinker" + ex);
-   } catch (IllegalAccessException ex) {
-      System.out.println("Check the entity linker properties file. The entry must be formatted as linker.<type>=<fullclassname>, i.e linker.person=org.my.company.MyPersonLinker" + ex);
-    } catch (ClassNotFoundException ex) {
-      System.out.println("Check the entity linker properties file. The entry must be formatted as linker.<type>=<fullclassname>, i.e linker.person=org.my.company.MyPersonLinker" + ex);
-    } catch (IOException ex) {
-      System.out.println("Check the entity linker properties file. The entry must be formatted as linker.<type>=<fullclassname>, i.e linker.person=org.my.company.MyPersonLinker" + ex);
-    }
+    } catch (Exception ex) {
+      System.out.println("Check the entity linker properties file. The entry must be formatted as linker.<type>=<fullclassname>, i.e linker.person=org.my.company.MyPersonLinker\n" + ex);
+   }
     return linker;
   }
 
-  /**
-   * Instantiates a list of EntityLinkers based on a properties file entry that
-   * consists of a comma separated list of full class names. The entityType is
-   * used to build the key to the properties entry. the entityType will be
-   * prefixed with "linker." Therefore, a compliant property entry for location
-   * entity linker types would be: linker.<yourtype>=<yourclass1,yourclass2> For
-   * example:
-   * linker.location=opennlp.tools.entitylinker.GeoEntityLinker,opennlp.tools.entitylinker.GeoEntityLinker2
-   *
-   *
-   * @param entityType the type of entity, the same as what would be returned
-   *                   from span.getType()
-   * @param properties the entitylinker properties that contain the configured
-   *                   entitylinkers
-   * @return *
-   */
-  @Deprecated
-  public static synchronized List<EntityLinker> getLinkers(String entityType, EntityLinkerProperties properties) {
-    List<EntityLinker> linkers = new ArrayList<EntityLinker>();
-    try {
-      String listoflinkers = properties.getProperty("linker." + entityType, GeoEntityLinker.class.getName());
-      for (String classname : listoflinkers.split(",")) {
-        Class theClass = Class.forName(classname);
-        EntityLinker linker = (EntityLinker) theClass.newInstance();
-        System.out.println("EntityLinker factory instantiated: " + linker.getClass().getName());
-        linker.setEntityLinkerProperties(properties);
-        linkers.add(linker);
-      }
-    } catch (InstantiationException ex) {
-      Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-    } catch (IllegalAccessException ex) {
-      Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-    } catch (ClassNotFoundException ex) {
-      Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-    } catch (IOException ex) {
-      Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-    }
-    return linkers;
-  }
-
-  /**
-   *
-   * @param entityTypes the types of entities, i.e person, location,
-   *                    organization
-   * @param properties  the entitylinker properties that contain the configured
-   *                    entitylinkers
-   * @return
-   */
-  @Deprecated
-  public static synchronized List<EntityLinker> getLinkers(String[] entityTypes, EntityLinkerProperties properties) {
-    List<EntityLinker> linkers = new ArrayList<EntityLinker>();
-
-    for (String entityType : entityTypes) {
-      try {
-        String listoflinkers = properties.getProperty("linker." + entityType, GeoEntityLinker.class.getName());
-        for (String classname : listoflinkers.split(",")) {
-          Class theClass = Class.forName(classname);
-          EntityLinker linker = (EntityLinker) theClass.newInstance();
-          System.out.println("EntityLinker factory instantiated: " + linker.getClass().getName());
-          linker.setEntityLinkerProperties(properties);
-          linkers.add(linker);
-        }
-      } catch (InstantiationException ex) {
-        Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-      } catch (IllegalAccessException ex) {
-        Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-      } catch (ClassNotFoundException ex) {
-        Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-      } catch (IOException ex) {
-        Logger.getLogger(EntityLinkerFactory.class.getName()).log(Level.SEVERE, null, ex);
-      }
-
-    }
-
-    return linkers;
-  }
 }

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/BaseLink.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/BaseLink.java?rev=1539314&r1=1539313&r2=1539314&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/BaseLink.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/BaseLink.java Wed Nov  6 11:41:43 2013
@@ -16,6 +16,7 @@
 package opennlp.tools.entitylinker.domain;
 
 import java.util.HashMap;
+import java.util.Objects;
 
 /**
  * Stores a minimal tuple of information. Intended to be used with LinkedSpan
@@ -28,8 +29,8 @@ public abstract class BaseLink {
   private String itemID;
   private String itemName;
   private String itemType;
-
   private HashMap<String, Double> scoreMap = new HashMap<String, Double>();
+
   public BaseLink() {
   }
 
@@ -40,8 +41,6 @@ public abstract class BaseLink {
     this.itemType = itemType;
   }
 
-
-
   public String getItemParentID() {
     return itemParentID;
   }
@@ -107,13 +106,6 @@ public abstract class BaseLink {
     this.itemType = itemType;
   }
 
-  @Override
-  public String toString() {
-    return "BaseLink{" + "itemID=" + itemID + ", itemName=" + itemName + ", itemType=" + itemType + '}';
-  }
-
- 
-
   public HashMap<String, Double> getScoreMap() {
     return scoreMap;
   }
@@ -121,4 +113,43 @@ public abstract class BaseLink {
   public void setScoreMap(HashMap<String, Double> scoreMap) {
     this.scoreMap = scoreMap;
   }
+
+  @Override
+  public String toString() {
+    return "BaseLink{" + "itemParentID=" + itemParentID + ", itemID=" + itemID + ", itemName=" + itemName + ", itemType=" + itemType + ", scoreMap=" + scoreMap + '}';
+  }
+
+  @Override
+  public int hashCode() {
+    int hash = 7;
+    hash = 71 * hash + Objects.hashCode(this.itemParentID);
+    hash = 71 * hash + Objects.hashCode(this.itemID);
+    hash = 71 * hash + Objects.hashCode(this.itemName);
+    hash = 71 * hash + Objects.hashCode(this.itemType);
+    return hash;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null) {
+      return false;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    final BaseLink other = (BaseLink) obj;
+    if (!Objects.equals(this.itemParentID, other.itemParentID)) {
+      return false;
+    }
+    if (!Objects.equals(this.itemID, other.itemID)) {
+      return false;
+    }
+    if (!Objects.equals(this.itemName, other.itemName)) {
+      return false;
+    }
+    if (!Objects.equals(this.itemType, other.itemType)) {
+      return false;
+    }
+    return true;
+  }
 }
\ No newline at end of file

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/LinkedSpan.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/LinkedSpan.java?rev=1539314&r1=1539313&r2=1539314&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/LinkedSpan.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/entitylinker/domain/LinkedSpan.java Wed Nov  6 11:41:43 2013
@@ -16,6 +16,7 @@
 package opennlp.tools.entitylinker.domain;
 
 import java.util.ArrayList;
+import java.util.Objects;
 import opennlp.tools.util.Span;
 
 /**
@@ -29,8 +30,6 @@ public class LinkedSpan<T extends BaseLi
   private int sentenceid = 0;
   private String searchTerm;
 
-
-  
   public LinkedSpan(ArrayList<T> linkedEntries, int s, int e, String type) {
     super(s, e, type);
     this.linkedEntries = linkedEntries;
@@ -61,6 +60,7 @@ public class LinkedSpan<T extends BaseLi
   public void setSentenceid(int sentenceid) {
     this.sentenceid = sentenceid;
   }
+
   public String getSearchTerm() {
     return searchTerm;
   }
@@ -68,14 +68,39 @@ public class LinkedSpan<T extends BaseLi
   public void setSearchTerm(String searchTerm) {
     this.searchTerm = searchTerm;
   }
+
   @Override
   public String toString() {
-    return "LinkedSpan{" + "linkedEntries=" + linkedEntries + '}';
+    return "LinkedSpan{" + "linkedEntries=" + linkedEntries + ", sentenceid=" + sentenceid + ", searchTerm=" + searchTerm + '}';
   }
 
+  @Override
+  public int hashCode() {
+    int hash = 7;
+    hash = 71 * hash + Objects.hashCode(this.linkedEntries);
+    hash = 71 * hash + this.sentenceid;
+    hash = 71 * hash + Objects.hashCode(this.searchTerm);
+    return hash;
+  }
 
-
-
-
-  
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null) {
+      return false;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    final LinkedSpan<T> other = (LinkedSpan<T>) obj;
+    if (!Objects.equals(this.linkedEntries, other.linkedEntries)) {
+      return false;
+    }
+    if (this.sentenceid != other.sentenceid) {
+      return false;
+    }
+    if (!Objects.equals(this.searchTerm, other.searchTerm)) {
+      return false;
+    }
+    return true;
+  }
 }
\ No newline at end of file