Search in sources :

Example 6 with Result

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;
}
Also used : TermNatures(org.ansj.domain.TermNatures) ArrayList(java.util.ArrayList) Term(org.ansj.domain.Term) Result(org.ansj.domain.Result)

Example 7 with Result

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()));
}
Also used : Result(org.ansj.domain.Result) Test(org.junit.Test)

Example 8 with Result

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;
}
Also used : ArrayList(java.util.ArrayList) Term(org.ansj.domain.Term) Result(org.ansj.domain.Result)

Example 9 with 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);
}
Also used : Result(org.ansj.domain.Result)

Example 10 with Result

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);
}
Also used : Result(org.ansj.domain.Result)

Aggregations

Result (org.ansj.domain.Result)16 Term (org.ansj.domain.Term)8 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 LearnTool (org.ansj.dic.LearnTool)1 TermNatures (org.ansj.domain.TermNatures)1 NatureRecognition (org.ansj.recognition.impl.NatureRecognition)1 SynonymsRecgnition (org.ansj.recognition.impl.SynonymsRecgnition)1 NlpAnalysis (org.ansj.splitWord.analysis.NlpAnalysis)1 Forest (org.nlpcn.commons.lang.tire.domain.Forest)1 Value (org.nlpcn.commons.lang.tire.domain.Value)1