use of org.ansj.domain.Result in project ansj_seg by NLPchina.
the class NatureRecognition method recognition.
/**
* 传入一组。词对词语进行。词性标注
*
* @param words
* @param offe
* @return
*/
public List<Term> recognition(List<String> words, int offe) {
List<Term> terms = new ArrayList<Term>(words.size());
int tempOffe = 0;
for (String word : words) {
TermNatures tn = getTermNatures(word);
terms.add(new Term(word, offe + tempOffe, tn));
tempOffe += word.length();
}
new NatureRecognition().recognition(new Result(terms));
return terms;
}
use of org.ansj.domain.Result in project ansj_seg by NLPchina.
the class IDCardRecognitionTest method test.
@Test
public void test() {
Result result = ToAnalysis.parse("我吃了一个西瓜,我今年25岁。13282619771220503X这里有一万个东西,我的身份证号码是130722198506280057h");
System.out.println(result.recognition(new IDCardRecognition()));
}
use of org.ansj.domain.Result in project ansj_seg by NLPchina.
the class Analysis method parse.
/**
* 通过构造方法传入的reader直接获取到分词结果
*
* @return
* @throws IOException
*/
public Result parse() throws IOException {
List<Term> list = new ArrayList<Term>();
Term temp = null;
while ((temp = next()) != null) {
list.add(temp);
}
Result result = new Result(list);
return result;
}
use of org.ansj.domain.Result in project ansj_seg by NLPchina.
the class BaseAnalysisDemo method main.
public static void main(String[] args) {
Result parse = BaseAnalysis.parse("让战士们过一个欢乐祥和的新春佳节。");
System.out.println(parse);
}
use of org.ansj.domain.Result in project ansj_seg by NLPchina.
the class DynamicWordDemo method main.
public static void main(String[] args) {
// 增加新词,中间按照'\t'隔开
DicLibrary.insert(DicLibrary.DEFAULT, "ansj中文分词", "userDefine", 1000);
Result terms = ToAnalysis.parse("我觉得Ansj中文分词是一个不错的系统!我是王婆!");
System.out.println("增加新词例子:" + terms);
// 删除词语,只能删除.用户自定义的词典.
DicLibrary.delete(DicLibrary.DEFAULT, "ansj中文分词");
terms = ToAnalysis.parse("我觉得ansj中文分词是一个不错的系统!我是王婆!");
System.out.println("删除用户自定义词典例子:" + terms);
}
Aggregations