mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r1465883 - in /mahout/trunk: CHANGELOG core/src/main/java/org/apache/mahout/common/lucene/AnalyzerUtils.java
Date Tue, 09 Apr 2013 05:27:18 GMT
Author: ssc
Date: Tue Apr  9 05:27:18 2013
New Revision: 1465883

URL: http://svn.apache.org/r1465883
Log:
MAHOUT-1161 Unable to run CJKAnalyzer for conversion of a sequence file to sparse vector due
to instantiation exception

Modified:
    mahout/trunk/CHANGELOG
    mahout/trunk/core/src/main/java/org/apache/mahout/common/lucene/AnalyzerUtils.java

Modified: mahout/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/mahout/trunk/CHANGELOG?rev=1465883&r1=1465882&r2=1465883&view=diff
==============================================================================
--- mahout/trunk/CHANGELOG (original)
+++ mahout/trunk/CHANGELOG Tue Apr  9 05:27:18 2013
@@ -2,6 +2,9 @@ Mahout Change Log
 
 Release 0.8 - unreleased
 
+  MAHOUT-1161: Unable to run CJKAnalyzer for conversion of a sequence file to sparse vector
due to instantiation
+               exception (ssc)
+
   MAHOUT-1184 Another take at pmd, findbugs and checkstyle (ssc)
 
   MAHOUT-1182: Remove useless append (Dave Brosius via tdunning)

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/common/lucene/AnalyzerUtils.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/common/lucene/AnalyzerUtils.java?rev=1465883&r1=1465882&r2=1465883&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/common/lucene/AnalyzerUtils.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/common/lucene/AnalyzerUtils.java Tue
Apr  9 05:27:18 2013
@@ -17,14 +17,12 @@ package org.apache.mahout.common.lucene;
  */
 
 import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.util.Version;
 import org.apache.mahout.common.ClassUtils;
 
 public final class AnalyzerUtils {
 
-  private AnalyzerUtils() {
-  }
+  private AnalyzerUtils() {}
 
   /**
    * Create an Analyzer using the latest {@link org.apache.lucene.util.Version}.  Note, if
you need to pass in
@@ -39,8 +37,6 @@ public final class AnalyzerUtils {
 
   public static Analyzer createAnalyzer(String analyzerClassName, Version version) throws
ClassNotFoundException {
     Class<? extends Analyzer> analyzerClass = Class.forName(analyzerClassName).asSubclass(Analyzer.class);
-    //TODO: GSI: Not sure I like this, many analyzers in Lucene take in the version
-
     return createAnalyzer(analyzerClass, version);
   }
 
@@ -55,18 +51,11 @@ public final class AnalyzerUtils {
   }
 
   public static Analyzer createAnalyzer(Class<? extends Analyzer> analyzerClass, Version
version) {
-    Analyzer analyzer;
-    if (analyzerClass == StandardAnalyzer.class) {
-      Class<?>[] params = new Class<?>[1];
-      params[0] = Version.class;
-      Object[] args = new Object[1];
-      args[0] = version;
-      analyzer = ClassUtils.instantiateAs(analyzerClass,
-              Analyzer.class, params, args);
-
-    } else {
-      analyzer = ClassUtils.instantiateAs(analyzerClass, Analyzer.class);
+    try {
+      return ClassUtils.instantiateAs(analyzerClass, Analyzer.class,
+          new Class<?>[] { Version.class }, new Object[] { version });
+    } catch (IllegalStateException e) {
+      return ClassUtils.instantiateAs(analyzerClass, Analyzer.class);
     }
-    return analyzer;
   }
 }



Mime
View raw message