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/01/19 16:11:10 UTC

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

Author: markg
Date: Sun Jan 19 15:11:10 2014
New Revision: 1559503

URL: http://svn.apache.org/r1559503
Log:
OPENNLP-637
OPENNLP-639
Added throws Exception to EntityLinkerFactory.getLinker. Updated javadocs and comments

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

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=1559503&r1=1559502&r2=1559503&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 Sun Jan 19 15:11:10 2014
@@ -55,50 +55,14 @@ public interface EntityLinker<T extends 
    * @param tokensBySentence a list of tokens that correspond to each sentence.
    *                         The outer array refers to the sentence, the inner
    *                         array is the tokens for the outer sentence. Similar
-   *                         in nature to Map<SentenceIndex,List<Tokens>> @param
-   *                         names
-   * B
-   * y    Sentence
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 a
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 list
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 of
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 name
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 spans
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 that
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 correspond
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 to
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 each
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 sentence.
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 The
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 outer
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 array
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 refers
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 to
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 the
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 sentence,
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 the
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 inner
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 array
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 refers
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 to
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 the
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 tokens
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 that
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 for
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 the
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 same
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 sentence.Similar
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 in
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 nature
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 to
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Map<SentenceIndex,List<Name
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Spans
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 For
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 This
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Sentence's
-   *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Tokens>>
-   *             @
-   * return
+   *                         in nature to Map of SentenceIndex keys to Listof
+   *                         tokens as values
+   * @param namesBySentence  a list of name spans that correspond to each
+   *                         sentence. The outer array refers to the sentence,
+   *                         the inner array refers to the tokens that for the
+   *                         same sentence.Similar in nature to
+   *                         Map<SentenceIndex,List<Name Spans For This
+   *                         Sentence's Tokens>> @ return
    */
   List<T> find(String doctext, Span[] sentences, String[][] tokensBySentence, Span[][] namesBySentence);
 

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=1559503&r1=1559502&r2=1559503&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 Sun Jan 19 15:11:10 2014
@@ -23,16 +23,16 @@ public class EntityLinkerFactory {
 
   /**
    *
-   * @param <I>        An type that extends EntityLinkerProperties.
+   * @param <I>        A type that extends EntityLinkerProperties.
    * @param entityType The type of entity being linked to. This value is used to
    *                   retrieve the implementation of the entitylinker from the
    *                   entitylinker properties file.
    * @param properties An object that extends EntityLinkerProperties. This
    *                   object will be passed into the implemented EntityLinker
-   *                   init(..) within this getLinker method.
+   *                   init(..) method, so it is an appropriate place to put additional resources.
    * @return an EntityLinker impl
    */
-  public static synchronized <I extends EntityLinkerProperties> EntityLinker getLinker(String entityType, I properties) {
+  public static synchronized <I extends EntityLinkerProperties> EntityLinker getLinker(String entityType, I properties)throws Exception {
     if (entityType == null || properties == null) {
       throw new IllegalArgumentException("Null argument in entityLinkerFactory");
     }
@@ -45,7 +45,7 @@ public class EntityLinkerFactory {
       linker.init(properties);
 
     } catch (Exception ex) {
-      System.out.println("Error in EntityLinker factory. 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);
+      throw new Exception("Error in EntityLinker factory. Check the entity linker properties file. The entry must be formatted as linker.<type>=<fullclassname>, i.e linker.person=org.my.company.MyPersonLinker",ex);
     }
     return linker;
   }