You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/07/25 05:33:30 UTC

svn commit: r1365426 - in /lucene/dev/branches/lucene2510/lucene/analysis: common/src/test/org/apache/lucene/analysis/core/ kuromoji/src/java/org/apache/lucene/analysis/ja/ uima/src/java/org/apache/lucene/analysis/uima/

Author: rmuir
Date: Wed Jul 25 03:33:29 2012
New Revision: 1365426

URL: http://svn.apache.org/viewvc?rev=1365426&view=rev
Log:
LUCENE-2510: fix more factory arg bugs found by TestFactories

Modified:
    lucene/dev/branches/lucene2510/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java
    lucene/dev/branches/lucene2510/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java
    lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java
    lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java

Modified: lucene/dev/branches/lucene2510/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2510/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java?rev=1365426&r1=1365425&r2=1365426&view=diff
==============================================================================
--- lucene/dev/branches/lucene2510/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java (original)
+++ lucene/dev/branches/lucene2510/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java Wed Jul 25 03:33:29 2012
@@ -39,6 +39,9 @@ import org.apache.lucene.analysis.util.T
  * we do our best to see if we can sanely initialize it with
  * no parameters and smoke test it, etc.
  */
+// TODO: move this, TestRandomChains, and TestAllAnalyzersHaveFactories
+// to an integration test module that sucks in all analysis modules.
+// currently the only way to do this is via eclipse etc (LUCENE-3974)
 public class TestFactories extends BaseTokenStreamTestCase {
   public void test() throws IOException {
     for (String tokenizer : TokenizerFactory.availableTokenizers()) {

Modified: lucene/dev/branches/lucene2510/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2510/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java?rev=1365426&r1=1365425&r2=1365426&view=diff
==============================================================================
--- lucene/dev/branches/lucene2510/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java (original)
+++ lucene/dev/branches/lucene2510/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java Wed Jul 25 03:33:29 2012
@@ -45,12 +45,15 @@ public class JapanesePartOfSpeechStopFil
   public void inform(ResourceLoader loader) {
     String stopTagFiles = args.get("tags");
     enablePositionIncrements = getBoolean("enablePositionIncrements", false);
+    stopTags = null;
     try {
       CharArraySet cas = getWordSet(loader, stopTagFiles, false);
-      stopTags = new HashSet<String>();
-      for (Object element : cas) {
-        char chars[] = (char[]) element;
-        stopTags.add(new String(chars));
+      if (cas != null) {
+        stopTags = new HashSet<String>();
+        for (Object element : cas) {
+          char chars[] = (char[]) element;
+          stopTags.add(new String(chars));
+        }
       }
     } catch (IOException e) {
       throw new InitializationException("IOException thrown while loading tags", e);
@@ -58,6 +61,7 @@ public class JapanesePartOfSpeechStopFil
   }
 
   public TokenStream create(TokenStream stream) {
-    return new JapanesePartOfSpeechStopFilter(enablePositionIncrements, stream, stopTags);
+    // if stoptags is null, it means the file is empty
+    return stopTags == null ? stream : new JapanesePartOfSpeechStopFilter(enablePositionIncrements, stream, stopTags);
   }
 }

Modified: lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java?rev=1365426&r1=1365425&r2=1365426&view=diff
==============================================================================
--- lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java (original)
+++ lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java Wed Jul 25 03:33:29 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.analysis.uima;
  */
 
 import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.InitializationException;
 import org.apache.lucene.analysis.util.TokenizerFactory;
 import org.apache.lucene.analysis.uima.UIMAAnnotationsTokenizer;
 
@@ -37,6 +38,9 @@ public class UIMAAnnotationsTokenizerFac
     super.init(args);
     descriptorPath = args.get("descriptorPath");
     tokenType = args.get("tokenType");
+    if (descriptorPath == null || tokenType == null) {
+      throw new InitializationException("Both descriptorPath and tokenType are mandatory");
+    }
   }
 
   @Override

Modified: lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java?rev=1365426&r1=1365425&r2=1365426&view=diff
==============================================================================
--- lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java (original)
+++ lucene/dev/branches/lucene2510/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java Wed Jul 25 03:33:29 2012
@@ -19,6 +19,7 @@ package org.apache.lucene.analysis.uima;
 
 import org.apache.lucene.analysis.Tokenizer;
 import org.apache.lucene.analysis.uima.UIMATypeAwareAnnotationsTokenizer;
+import org.apache.lucene.analysis.util.InitializationException;
 import org.apache.lucene.analysis.util.TokenizerFactory;
 
 import java.io.Reader;
@@ -39,6 +40,9 @@ public class UIMATypeAwareAnnotationsTok
     descriptorPath = args.get("descriptorPath");
     tokenType = args.get("tokenType");
     featurePath = args.get("featurePath");
+    if (descriptorPath == null || tokenType == null || featurePath == null) {
+      throw new InitializationException("descriptorPath, tokenType, and featurePath are mandatory");
+    }
   }
 
   @Override