标签:
大体上参考链接:http://blog.csdn.net/luojinping/article/details/8788743
最后注意下SegTag.java文件
1 public SegTag(int segPathCount) { 2 this.segPathCount = segPathCount; 3 coreDict = new Dictionary("data\\coreDict.dct"); 4 bigramDict = new Dictionary("data\\bigramDict.dct"); 5 personTagger = new PosTagger(Utility.TAG_TYPE.TT_PERSON, "data\\nr", coreDict); 6 transPersonTagger = new PosTagger(Utility.TAG_TYPE.TT_TRANS_PERSON, "data\\tr", coreDict); 7 placeTagger = new PosTagger(Utility.TAG_TYPE.TT_TRANS_PERSON, "data\\ns", coreDict); 8 lexTagger = new PosTagger(Utility.TAG_TYPE.TT_NORMAL, "data\\lexical", coreDict); 9 }
然而ictclas4j解压后的文件是Data,以及他目录下的是BigramDict.dct,所以先把这两个首字母改成小写的。
另外,如果是在Linux环境下,将路径分隔符改成/,否则切割词的时候,会出现一个一个的情况
如果不希望出现词语 后面带属性的结果,找到SegTag文件,里面的outputResult方法,将其最后的代码改成如下所示:
1 // 根据分词路径生成分词结果 2 private String outputResult(ArrayList<SegNode> wrList) { 3 String result = null; 4 String temp=null; 5 char[] pos = new char[2]; 6 if (wrList != null && wrList.size() > 0) { 7 result = ""; 8 for (int i = 0; i < wrList.size(); i++) { 9 SegNode sn = wrList.get(i); 10 if (sn.getPos() != POSTag.SEN_BEGIN && sn.getPos() != POSTag.SEN_END) { 11 int tag = Math.abs(sn.getPos()); 12 pos[0] = (char) (tag / 256); 13 pos[1] = (char) (tag % 256); 14 temp=""+pos[0]; 15 if(pos[1]>0) 16 temp+=""+pos[1]; 17 // result += sn.getSrcWord() + "/" + temp + " "; 18 result += sn.getSrcWord() + " "; 19 } 20 } 21 }
标签:
原文地址:http://www.cnblogs.com/nashiyue/p/4725377.html