返回信息流rt,毕设中要用到分词,直接运行目录下java平台的sample一直提示的初始化失败,不知道是哪儿的问题
这是一条镜像帖。来源:北邮人论坛 / ml-dm / #12701同步于 2014/3/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
ML_DM机器人发帖
[问题]有人使过java平台下NLPIR的中文分词么?
t01
2014/3/25镜像同步16 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
nlpir好像就是ictclas中科院分词系统对吧。胡乱贴点代码,以前写的,包是现成的,调用的方法也是网上查来的,他们提供官方的文档的。lz将就看吧。有不明白的欢迎站内交流。。。。
import java.io.*;
import org.dom4j.DocumentException;
import org.ictclas4j.bean.SegResult;
import org.ictclas4j.segment.SegTag;
public class Segmentation {
private static final String fileName = new Parameter().fileName();
private static final String directory = new Parameter().directory();
public void seg(String inputFilePath,
String outputFilePath) throws IOException,
DocumentException{
File f = new File(outputFilePath);//
FileWriter fw = new FileWriter(f);
BufferedWriter bw = new BufferedWriter(fw);
File fr = new File (inputFilePath);
FileReader fre = new FileReader(fr);
BufferedReader br = new BufferedReader(fre);
String s;
while((s=br.readLine())!=null){
SegTag segTag = new SegTag(1);// 分词
SegResult segResult = segTag.split(s.trim());
String b = segResult.getFinalResult();
//System.out.println(b);
bw.write(b+"\r\n");
}
br.close();
bw.close();
}
public static void main(String s[]) throws IOException, DocumentException{
String inputFilePath = directory+fileName+"Abstract.txt";
String outputFilePath = directory+fileName+"Split.txt";
new Segmentation().seg(inputFilePath, outputFilePath);
}
}
【 在 t01 的大作中提到: 】
: rt,毕设中要用到分词,直接运行目录下java平台的sample一直提示的初始化失败,不知道是哪儿的问题