yuntians / paoding

Automatically exported from code.google.com/p/paoding
0 stars 0 forks source link

This AttributeSource does not have the attribute: TermAttribute #102

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I included PaodingTokeizr into classifier4J to make it supportive for Chinese, 
following this: 
http://www.cnblogs.com/chenying99/archive/2013/07/12/3185379.html

And I got this exception: java.lang.IllegalArgumentException: 

This AttributeSource does not have the attribute 
'org.apache.lucene.analysis.tokenattributes.TermAttribute'.
at org.apache.lucene.util.AttributeSource.getAttribute(AttributeSource.java:265)
    at net.sf.classifier4J.PaodingTokenizer.tokenize(PaodingTokenizer.java:24)
    at net.sf.classifier4J.Utilities.getWordFrequency(Utilities.java:102)
    at net.sf.classifier4J.Utilities.getWordFrequency(Utilities.java:82)
    at net.sf.classifier4J.Utilities.getWordFrequency(Utilities.java:77)
    at net.sf.classifier4J.summariser.SimpleSummariser.summarise(SimpleSummariser.java:82)

My version: paoding-analysis-2.0.4-beta, lucene-core-3.0.0

I don't know what attribute the exception refers. Is this about the .properties 
files?

Original issue reported on code.google.com by helenf...@gmail.com on 23 Sep 2013 at 1:02

GoogleCodeExporter commented 8 years ago
已解决。我看的那个资源写错了一行代码。
这句是错的:TermAttribute termAtt = 
(TermAttribute)ts.getAttribute(TermAttribute.class);
这句是对的:TermAttribute termAtt = 
(TermAttribute)ts.addAttribute(TermAttribute.class);        

Original comment by helenf...@gmail.com on 24 Sep 2013 at 7:16