首页 新闻 会员 周边 捐助

求大神指教为什么报这个错

0
悬赏园豆:20 [已解决问题] 解决于 2016-04-13 10:47

这是我的源码,我用的paoding-analysis4.2.0.jar,为什么运行之后会报这个错误?

package myTest;

import java.io.StringReader;

//import net.paoding.analysis.analyzer.PaodingAnalyzer;



import net.paoding.analysis.analyzer.PaodingAnalyzer;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.wltea.analyzer.lucene.IKAnalyzer;

/**
 * 中文分词
 * @author zhh
 * 极易分词不支持Lucene3 不作测试
 *
 */
public class ChineseAnalyzer {

    public static void main(String[] args) throws Exception{
        ReadFileUtils rf = new ReadFileUtils();
        String s = "我是一名开发人员";
//        s = rf.readWORD2007("C:\\Users\\Crazy.J\\Desktop\\test.docx");
        String strZH = s;
        
//        Analyzer analyzer01 = new IKAnalyzer(true);    //当为true时,分词器进行智能切分
        Analyzer analyzer02 = new PaodingAnalyzer();
        
//        showAnalyzerResult(analyzer01, strZH);
        showAnalyzerResult(analyzer02, strZH);
        
    }
    
    public static void showAnalyzerResult(Analyzer analyzer, String str) throws Exception {
        long start = System.currentTimeMillis();
        System.out.println("\n" + analyzer.getClass().getSimpleName());
        StringReader reader = new StringReader(str); 
        TokenStream ts = analyzer.tokenStream("", reader);
        TermAttribute termAttribute =ts.getAttribute(TermAttribute.class); 
        
        long end = System.currentTimeMillis();
        long time = end - start;
        System.out.println("耗时:" + time + "ms");
        
        while (ts.incrementToken()) { 
               System.out.print(termAttribute.term() + "|");                                       
        } 
        
    }
    
}

 

 报了这个错

 

Exception in thread "main" net.paoding.analysis.exception.PaodingAnalysisException: please set a system env PAODING_DIC_HOME or Config paoding.dic.home in paoding-dic-home.properties point to the dictionaries!
    at net.paoding.analysis.knife.PaodingMaker.setDicHomeProperties(PaodingMaker.java:329)
    at net.paoding.analysis.knife.PaodingMaker.getDicHome(PaodingMaker.java:270)
    at net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:198)
    at net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:237)
    at net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:237)
    at net.paoding.analysis.knife.PaodingMaker.getProperties(PaodingMaker.java:135)
    at net.paoding.analysis.analyzer.PaodingAnalyzer.init(PaodingAnalyzer.java:70)
    at net.paoding.analysis.analyzer.PaodingAnalyzer.<init>(PaodingAnalyzer.java:59)
    at net.paoding.analysis.analyzer.PaodingAnalyzer.<init>(PaodingAnalyzer.java:52)
    at myTest.ChineseAnalyzer.main(ChineseAnalyzer.java:31)

 

 

wangxing.xu的主页 wangxing.xu | 初学一级 | 园豆:127
提问于:2016-04-01 11:39
< >
分享
最佳答案
0

 

让你设置PAODING_DIC_HOME 这个环境变量呢

 

收获园豆:20
sz_zzm | 菜鸟二级 |园豆:293 | 2016-04-02 17:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册