Search in sources :

Example 11 with Result

use of org.ansj.domain.Result in project ansj_seg by NLPchina.

the class JianFanZhuanhuanDemo method main.

public static void main(String[] args) {
    MyStaticValue.isRealName = true;
    List<String> all = new ArrayList<String>();
    all.add("關注十八大:台港澳密集解讀十八大報告”");
    all.add("关注十八大:台港澳密集解读十八大报告”");
    all.add("參選國民黨主席? 胡志強首度鬆口稱“會考慮”");
    all.add("参选国民党主席? 胡志强首度鬆口称“会考虑”");
    all.add("駁謝長廷“國民黨像東廠” 藍營吁其勿惡意嘲諷");
    all.add("驳谢长廷“国民党像东厂” 蓝营吁其勿恶意嘲讽");
    all.add("台藝人陳俊生出軌逼死女友 絕情獸行遭曝光");
    all.add("台艺人陈俊生出轨逼死女友 绝情兽行遭曝光");
    all.add("林益世想回高雄探母 法官警告勿有逃亡念頭");
    all.add("林益世想回高雄探母 法官警告勿有逃亡念头");
    all.add("吳伯雄談建言被誤解讀:盡點言責 絕對善意");
    all.add("輸入簡體字,點下面繁體字按鈕進行在線轉換.");
    for (String string : all) {
        Result parse = NlpAnalysis.parse(string);
        System.out.println(parse);
    }
}
Also used : ArrayList(java.util.ArrayList) Result(org.ansj.domain.Result)

Example 12 with Result

use of org.ansj.domain.Result in project ansj_seg by NLPchina.

the class NatureDemo method main.

public static void main(String[] args) throws IOException {
    Result terms = ToAnalysis.parse("Ansj中文分词是一个真正的ict的实现.并且加入了自己的一些数据结构和算法的分词.实现了高效率和高准确率的完美结合!");
    //词性标注
    terms.recognition(new NatureRecognition());
    System.out.println(terms);
}
Also used : NatureRecognition(org.ansj.recognition.impl.NatureRecognition) Result(org.ansj.domain.Result)

Example 13 with Result

use of org.ansj.domain.Result in project ansj_seg by NLPchina.

the class RealWordDemo method main.

public static void main(String[] args) {
    // 默认方式
    Result parse = ToAnalysis.parse("Hello word是每个程序员必经之路");
    System.out.println(parse);
    // 保证方式
    MyStaticValue.isRealName = true;
    parse = ToAnalysis.parse("Hello word是每个程序员必经之路");
    for (Term term : parse) {
        System.out.print(term.getRealName() + " ");
    }
}
Also used : Term(org.ansj.domain.Term) Result(org.ansj.domain.Result)

Example 14 with Result

use of org.ansj.domain.Result in project ansj_seg by NLPchina.

the class DicLibraryTest method insertTest2.

/**
	 * 增加关键词
	 *
	 * @param keyword
	 */
@Test
public void insertTest2() {
    DicLibrary.insert(DicLibrary.DEFAULT, "增加新词");
    Result parse = DicAnalysis.parse("这是用户自定义词典增加新词的例子");
    System.out.println(parse);
    boolean flag = false;
    for (Term term : parse) {
        flag = flag || "增加新词".equals(term.getName());
    }
    Assert.assertTrue(flag);
}
Also used : Term(org.ansj.domain.Term) Result(org.ansj.domain.Result) Test(org.junit.Test)

Example 15 with Result

use of org.ansj.domain.Result in project ansj_seg by NLPchina.

the class DicLibraryTest method insertTest.

/**
	 * 关键词增加
	 *
	 * @param keyword 所要增加的关键词
	 * @param nature 关键词的词性
	 * @param freq 关键词的词频
	 */
@Test
public void insertTest() {
    DicLibrary.insert(DicLibrary.DEFAULT, "增加新词", "我是词性", 1000);
    Result parse = DicAnalysis.parse("这是用户自定义词典增加新词的例子");
    System.out.println(parse);
    boolean flag = false;
    for (Term term : parse) {
        flag = flag || "增加新词".equals(term.getName());
    }
    Assert.assertTrue(flag);
}
Also used : Term(org.ansj.domain.Term) Result(org.ansj.domain.Result) Test(org.junit.Test)

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