xjt927 2011-07-26 11:58
浏览 255
已采纳

paoding分词器的问题,各位看看能解决不??

package cn.itcast.lucene.analyzer;

import java.io.StringReader;

import jeasy.analysis.MMAnalyzer;

import net.paoding.analysis.analyzer.PaodingAnalyzer;
import net.paoding.analysis.knife.Paoding;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.cjk.CJKAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.junit.Test;

public class AnalyzerTest {

String enText = "IndexWriter addDocument's a javadoc.txt";
// String zhText = "我们是中国人";
// String zhText = "小笑话_总统的房间 Room .txt";
String zhText = "一位绅士到旅游胜地的一家饭店要开个房间";

Analyzer en1 = new StandardAnalyzer(); // 单字分词
Analyzer en2 = new SimpleAnalyzer();

Analyzer zh1 = new CJKAnalyzer(); // 二分法分词
Analyzer zh2 = new MMAnalyzer(); // 词库分词
Analyzer zh3 = new PaodingAnalyzer(); 

@Test
public void test() throws Exception {
    // analyze(en2, enText);
    // analyze(en1, zhText);

    // analyze(zh1, zhText);[size=xx-small][/size]
    analyze(zh3, zhText);
}

public void analyze(Analyzer analyzer, String text) throws Exception {
    System.out.println("--> 分词器:" + analyzer.getClass());
    TokenStream tokenStream = analyzer.tokenStream("content", new StringReader(text));
    for (Token token = new Token(); (token = tokenStream.next(token)) != null;) {
        System.out.println(token);
    }
}

}

[color=darkred]在项目里创建了paoding-dic-home.properties这个文件,内容如下:[/color]
paoding.dic.home=E:/lucene/paoding-analysis-2.0.4-beta/dic
paoding.dic.detector.interval=60

[color=darkred]当加上PaoDing分词器的时候就报错,注释掉就没有问题。
错误如下:[/color]
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:320)
at net.paoding.analysis.knife.PaodingMaker.getDicHome(PaodingMaker.java:261)
at net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:189)
at net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:228)
at net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:228)
at net.paoding.analysis.knife.PaodingMaker.getProperties(PaodingMaker.java:130)
at net.paoding.analysis.analyzer.PaodingAnalyzer.init(PaodingAnalyzer.java:70)
at net.paoding.analysis.analyzer.PaodingAnalyzer.(PaodingAnalyzer.java:59)
at net.paoding.analysis.analyzer.PaodingAnalyzer.(PaodingAnalyzer.java:52)
at cn.itcast.lucene.analyzer.AnalyzerTest11.(AnalyzerTest11.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:171)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:216)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:213)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

  • 写回答

4条回答 默认 最新

  • successfulroof 2011-07-28 08:31
    关注

    你Properties里面目录有问题,不是使用E盘什么的,是项目路径
    paoding.dic.home=/data/paoding/dic 这样类似,自己去改

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 VB6可以成功读取的文件,用C#读不了
  • ¥15 如何使用micpyhon解析Modbus RTU返回指定站号的湿度值,并确保正确?
  • ¥15 C++ 句柄后台鼠标拖动如何实现
  • ¥15 有人会SIRIUS 5.8.0这个软件吗
  • ¥30 comsol仿真等离激元
  • ¥15 静电纺丝煅烧后如何得到柔性纤维
  • ¥15 (标签-react native|关键词-镜像源)
  • ¥100 照片生成3D人脸视频
  • ¥15 伪装视频时长问题修改MP4的时长问题,
  • ¥15 JETSON NANO