Search in sources :

Example 6 with Value

use of org.nlpcn.commons.lang.tire.domain.Value in project ansj_seg by NLPchina.

the class DicLibrary method insert.

/**
	 * 关键词增加
	 *
	 * @param keyword 所要增加的关键词
	 * @param nature 关键词的词性
	 * @param freq 关键词的词频
	 */
public static void insert(String key, String keyword, String nature, int freq) {
    Forest dic = get(key);
    String[] paramers = new String[2];
    paramers[0] = nature;
    paramers[1] = String.valueOf(freq);
    Value value = new Value(keyword, paramers);
    Library.insertWord(dic, value);
}
Also used : MyStaticValue(org.ansj.util.MyStaticValue) Value(org.nlpcn.commons.lang.tire.domain.Value) Forest(org.nlpcn.commons.lang.tire.domain.Forest)

Example 7 with Value

use of org.nlpcn.commons.lang.tire.domain.Value in project ansj_seg by NLPchina.

the class ReloadAmbiguityLibrary method loadFormStr.

private static void loadFormStr() {
    Forest forest = AmbiguityLibrary.get();
    //方法1
    Value value = new Value("三个和尚", "三个", "m", "和尚", "n");
    Library.insertWord(forest, value);
    //方法2 
    AmbiguityLibrary.insert(AmbiguityLibrary.DEFAULT, "三个", "m", "和尚", "n");
    // 将新构建的辞典树替换掉旧的。
    AmbiguityLibrary.put(AmbiguityLibrary.DEFAULT, AmbiguityLibrary.DEFAULT, forest);
}
Also used : Value(org.nlpcn.commons.lang.tire.domain.Value) Forest(org.nlpcn.commons.lang.tire.domain.Forest)

Aggregations

Value (org.nlpcn.commons.lang.tire.domain.Value)7 Forest (org.nlpcn.commons.lang.tire.domain.Forest)4 MyStaticValue (org.ansj.util.MyStaticValue)2 BufferedReader (java.io.BufferedReader)1 HashMap (java.util.HashMap)1 CorpusTest (org.ansj.CorpusTest)1 Result (org.ansj.domain.Result)1 Term (org.ansj.domain.Term)1 Test (org.junit.Test)1