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 2014/03/11 11:49:24 UTC

svn commit: r1576275 - in /opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools: entitylinker/EntityLinker.java entitylinker/EntityLinkerFactory.java util/InputStreamFactory.java

Author: markg
Date: Tue Mar 11 10:49:23 2014
New Revision: 1576275

URL: http://svn.apache.org/r1576275
Log:
OPENNLP-655
EntitylinkerFactory now throws IOException, therefore EntityLinker#init also throws IOException. 

Modified:
    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/util/InputStreamFactory.java

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=1576275&r1=1576274&r2=1576275&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 Tue Mar 11 10:49:23 2014
@@ -15,6 +15,7 @@
  */
 package opennlp.tools.entitylinker;
 
+import java.io.IOException;
 import java.util.List;
 
 import opennlp.tools.util.Span;
@@ -42,8 +43,9 @@ public interface EntityLinker<T extends 
    * @param initializationData the EntityLinkerProperties object that contains
    *                           properties needed by the impl, as well as any
    *                           other objects required for the impl
+   * @throws java.io.IOException
    */
-  void init(EntityLinkerProperties initializationData) throws Exception;
+  void init(EntityLinkerProperties initializationData) throws IOException;
 
   /**
    * Links an entire document of named entities to an external source

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=1576275&r1=1576274&r2=1576275&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 Tue Mar 11 10:49:23 2014
@@ -15,6 +15,7 @@
  */
 package opennlp.tools.entitylinker;
 
+import java.io.IOException;
 import opennlp.tools.util.ext.ExtensionLoader;
 
 /**
@@ -33,8 +34,9 @@ public class EntityLinkerFactory {
    *                   object will be passed into the implemented EntityLinker
    *                   init(..) method, so it is an appropriate place to put additional resources.
    * @return an EntityLinker impl
+   * @throws java.io.IOException
    */
-  public static synchronized EntityLinker<?> getLinker(String entityType, EntityLinkerProperties properties) throws Exception {
+  public static synchronized EntityLinker<?> getLinker(String entityType, EntityLinkerProperties properties) throws IOException {
     if (entityType == null || properties == null) {
       throw new IllegalArgumentException("Null argument in entityLinkerFactory");
     }
@@ -49,4 +51,31 @@ public class EntityLinkerFactory {
     linker.init(properties);
     return linker;
   }
+
+
+   /**
+   *
+
+
+   * @param properties An object that extends EntityLinkerProperties. This
+   *                   object will be passed into the implemented EntityLinker
+   *                   init(..) method, so it is an appropriate place to put additional resources.
+   * @return an EntityLinker impl
+   * @throws java.io.IOException
+   */
+  public static synchronized EntityLinker<?> getLinker( EntityLinkerProperties properties) throws IOException {
+    if (properties == null) {
+      throw new IllegalArgumentException("Null argument in entityLinkerFactory");
+    }
+
+    String linkerImplFullName = properties.getProperty("linker","");
+
+    if (linkerImplFullName == null || linkerImplFullName.equals("")) {
+      throw new IllegalArgumentException("linker property must be set!");
+    }
+
+    EntityLinker<?> linker = ExtensionLoader.instantiateExtension(EntityLinker.class, linkerImplFullName);
+    linker.init(properties);
+    return linker;
+  }
 }

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/InputStreamFactory.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/InputStreamFactory.java?rev=1576275&r1=1576274&r2=1576275&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/InputStreamFactory.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/InputStreamFactory.java Tue Mar 11 10:49:23 2014
@@ -24,7 +24,6 @@ import java.io.InputStream;
  * Use {@link MockInputStreamFactory} MockInputStreamFactory for default
  * behavior.
  *
- * @author Owner
  */
 public interface InputStreamFactory {