Author: jeastman
Date: Sun May 23 22:30:05 2010
New Revision: 947513
URL: http://svn.apache.org/viewvc?rev=947513&view=rev
Log:
Added an exception handler and nicer message if --numWords is set too small and
causes an ArrayIndexOutOfBoundsException
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAMapper.java
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAMapper.java
URL:
http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAMapper.java?rev=947513&r1=947512&r2=947513&view=diff
==============================================================================
---
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAMapper.java
(original)
+++
mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAMapper.java
Sun May 23 22:30:05 2010
@@ -42,7 +42,15 @@ public class LDAMapper extends Mapper<Wr
public void map(WritableComparable<?> key, VectorWritable
wordCountsWritable, Context context) throws IOException,
InterruptedException {
Vector wordCounts = wordCountsWritable.get();
- LDAInference.InferredDocument doc = infer.infer(wordCounts);
+ LDAInference.InferredDocument doc = null;
+ try {
+ doc = infer.infer(wordCounts);
+ } catch (ArrayIndexOutOfBoundsException e1) {
+ throw new IllegalStateException(
+ "This is probably because the --numWords argument is set too small.
\n"
+ + "\tIt needs to be >= than the number of words (terms actually) in
the corpus and can be \n"
+ + "\tlarger if some storage inefficiency can be tolerated.", e1);
+ }
double[] logTotals = new double[state.numTopics];
Arrays.fill(logTotals, Double.NEGATIVE_INFINITY);