You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2011/07/05 09:58:32 UTC
svn commit: r1142914 - in /mahout/trunk:
core/src/main/java/org/apache/mahout/classifier/
core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/
integration/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/
Author: srowen
Date: Tue Jul 5 07:58:32 2011
New Revision: 1142914
URL: http://svn.apache.org/viewvc?rev=1142914&view=rev
Log:
More change from TermAttribute to CharTermAttribute
Modified:
mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java
mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java
mahout/trunk/integration/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/BloomTokenFilterTest.java
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java?rev=1142914&r1=1142913&r2=1142914&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/classifier/BayesFileFormatter.java Tue Jul 5 07:58:32 2011
@@ -40,7 +40,7 @@ import org.apache.commons.cli2.commandli
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -207,11 +207,11 @@ public final class BayesFileFormatter {
writer.write(label);
writer.write('\t'); // edit: Inorder to match Hadoop standard
// TextInputFormat
- TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
+ CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
ts.reset();
while (ts.incrementToken()) {
- char[] termBuffer = termAtt.termBuffer();
- int termLen = termAtt.termLength();
+ char[] termBuffer = termAtt.buffer();
+ int termLen = termAtt.length();
writer.write(termBuffer, 0, termLen);
writer.write(' ');
}
@@ -233,11 +233,11 @@ public final class BayesFileFormatter {
TokenStream ts = analyzer.reusableTokenStream("", reader);
List<String> coll = Lists.newArrayList();
- TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
+ CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
ts.reset();
while (ts.incrementToken()) {
- char[] termBuffer = termAtt.termBuffer();
- int termLen = termAtt.termLength();
+ char[] termBuffer = termAtt.buffer();
+ int termLen = termAtt.length();
String val = new String(termBuffer, 0, termLen);
coll.add(val);
}
Modified: mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java?rev=1142914&r1=1142913&r2=1142914&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java (original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/classifier/bayes/mapreduce/common/BayesFeatureMapper.java Tue Jul 5 07:58:32 2011
@@ -30,7 +30,7 @@ import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.lucene.analysis.shingle.ShingleFilter;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.mahout.classifier.bayes.BayesParameters;
import org.apache.mahout.common.StringTuple;
import org.apache.mahout.common.lucene.IteratorTokenStream;
@@ -79,7 +79,7 @@ public class BayesFeatureMapper extends
if (gramSize > 1) {
ShingleFilter sf = new ShingleFilter(new IteratorTokenStream(Iterators.forArray(tokens)), gramSize);
do {
- String term = sf.getAttribute(TermAttribute.class).term();
+ String term = sf.getAttribute(CharTermAttribute.class).toString();
if (term.length() > 0) {
if (wordList.containsKey(term)) {
wordList.put(term, 1 + wordList.get(term));
Modified: mahout/trunk/integration/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/BloomTokenFilterTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/BloomTokenFilterTest.java?rev=1142914&r1=1142913&r2=1142914&view=diff
==============================================================================
--- mahout/trunk/integration/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/BloomTokenFilterTest.java (original)
+++ mahout/trunk/integration/src/test/java/org/apache/mahout/utils/nlp/collocations/llr/BloomTokenFilterTest.java Tue Jul 5 07:58:32 2011
@@ -33,7 +33,7 @@ import org.apache.hadoop.util.hash.Hash;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.analysis.shingle.ShingleFilter;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.util.Version;
import org.apache.mahout.utils.MahoutTestCase;
import org.junit.Test;
@@ -122,8 +122,8 @@ public final class BloomTokenFilterTest
int pos = 0;
while (ts.incrementToken()) {
assertTrue("Analyzer produced too many tokens", pos <= expected.length);
- TermAttribute termAttr = ts.getAttribute(TermAttribute.class);
- assertEquals("Unexpected term", expected[pos++], termAttr.term());
+ CharTermAttribute termAttr = ts.getAttribute(CharTermAttribute.class);
+ assertEquals("Unexpected term", expected[pos++], termAttr.toString());
}
assertEquals("Analyzer produced too few terms", expected.length, pos);
}