BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / java / #22318同步于 2012/5/1
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖

求助~Exception in thread "main" java.lang.Error: Unresolved

zhudoudou
2012/5/1镜像同步1 回复
别人用ictclas分词的一个接口程序,我只要用下但一直出错,求大家耐心看完~帮帮忙! import java.io.*; import java.util.ArrayList; import wordseg.ICTCLAS30; public class SplitWords { ICTCLAS30 testICTCLAS30 = null; void Init() throws IOException { try { testICTCLAS30 = new ICTCLAS30(); if (testICTCLAS30.Init("ictclas30") == false) // GB2312 { System.out.println("Init Fail!"); return; } String sUserDict = "userdic.txt"; int nCount = testICTCLAS30.ImportUserDict("ictclas30/userdict.txt"); } catch (Exception ex) { } } public void end() { testICTCLAS30.Exit(); // oSegment.Exit(); } public void SegToWords(String content, ArrayList<String> wordarr, ArrayList<String> posarr) { int nPos; String word, pos; String nativeStr = testICTCLAS30.ParagraphProcess(content, true); nativeStr = nativeStr.trim(); String[] itemStrings = nativeStr.split(" "); for (String itemstr : itemStrings) { if (itemstr.equals("")) continue; nPos = itemstr.indexOf("/"); // if(nPos<0) nPos+=0; word = itemstr.substring(0, nPos); if (word.equals("")) continue; pos = itemstr.substring(nPos + 1); wordarr.add(word); posarr.add(pos); } } public void SplitW() throws Exception { Init();//初始化 BufferedReader br = null;//定义一个字符流缓冲区,用来读入文件 br = new BufferedReader(new FileReader(new File("dress.txt"))); BufferedWriter sym_writer = new BufferedWriter(new FileWriter("doneword1.txt"));//缓冲区,用来写文件 ArrayList<String> wordarr = new ArrayList<String>(); ArrayList<String> posarr = new ArrayList<String>(); String content = null; while(br != null){ content = br.readLine(); String newfile = "";//定义一个字符串将wordarr里的每个词间加入空格合并,以写入文本 SegToWords(content, wordarr, posarr); for (int j = 0; j < wordarr.size(); j++) { newfile += wordarr.get(j)+"\t"; } //System.out.print(newfile+"\n"); sym_writer.write(newfile+""); sym_writer.write("\n"); wordarr.clear(); posarr.clear(); } sym_writer.close(); // delete the recurrance in the single doc end(); } /** * @param args * @throws IOException */ public static void main(String[] args) throws Exception { System.out.print("begin"); SplitWords sw = new SplitWords(); sw.SplitW(); System.out.print("end"); } }
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复
zhudoudou机器人#1 · 2012/5/1
ps.环境变量已经设置正确~