You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by co...@apache.org on 2012/03/13 15:50:37 UTC

svn commit: r1300164 - in /opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind: NameFinderME.java TokenNameFinderModel.java

Author: colen
Date: Tue Mar 13 14:50:36 2012
New Revision: 1300164

URL: http://svn.apache.org/viewvc?rev=1300164&view=rev
Log:
OPENNLP-463: Check if resources is null

Modified:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/TokenNameFinderModel.java

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java?rev=1300164&r1=1300163&r2=1300164&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java Tue Mar 13 14:50:36 2012
@@ -189,7 +189,9 @@ public class NameFinderME implements Tok
           generatorDescriptor), new FeatureGeneratorResourceProvider() {
 
         public Object getResource(String key) {
-          return resources.get(key);
+          if (resources != null)
+            return resources.get(key);
+          return null;
         }
       });
     } else {

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/TokenNameFinderModel.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/TokenNameFinderModel.java?rev=1300164&r1=1300163&r2=1300164&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/TokenNameFinderModel.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/TokenNameFinderModel.java Tue Mar 13 14:50:36 2012
@@ -81,20 +81,21 @@ public class TokenNameFinderModel extend
 
     artifactMap.put(MAXENT_MODEL_ENTRY_NAME, nameFinderModel);
     
-    // TODO: Null check ?!
     if (generatorDescriptor != null && generatorDescriptor.length > 0)
       artifactMap.put(GENERATOR_DESCRIPTOR_ENTRY_NAME, generatorDescriptor);
     
-    // The resource map must not contain key which are already taken
-    // like the name finder maxent model name
-    if (resources.containsKey(MAXENT_MODEL_ENTRY_NAME) ||
-        resources.containsKey(GENERATOR_DESCRIPTOR_ENTRY_NAME)) {
-      throw new IllegalArgumentException();
+    if (resources != null) {
+      // The resource map must not contain key which are already taken
+      // like the name finder maxent model name
+      if (resources.containsKey(MAXENT_MODEL_ENTRY_NAME) ||
+          resources.containsKey(GENERATOR_DESCRIPTOR_ENTRY_NAME)) {
+        throw new IllegalArgumentException();
+      }
+      
+      // TODO: Add checks to not put resources where no serializer exists,
+      // make that case fail here, should be done in the BaseModel
+      artifactMap.putAll(resources); 
     }
-    
-    // TODO: Add checks to not put resources where no serializer exists,
-    // make that case fail here, should be done in the BaseModel
-    artifactMap.putAll(resources);
     checkArtifactMap();
   }