本文整理汇总了Java中org.ansj.domain.Term.natrue方法的典型用法代码示例。如果您正苦于以下问题:Java Term.natrue方法的具体用法?Java Term.natrue怎么用?Java Term.natrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ansj.domain.Term
的用法示例。
在下文中一共展示了Term.natrue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergerId
import org.ansj.domain.Term; //导入方法依赖的package包/类
private static int mergerId(List<Term> parse, StringBuilder sb, int i) {
// TODO Auto-generated method stub
Term term = null;
String natureStr = null;
int j = i + 1;
for (; j < parse.size(); j++) {
term = parse.get(j);
natureStr = term.natrue().natureStr;
if ("en".equals(natureStr) || "m".equals(natureStr) || "-".equals(term.getName()) || ":".equals(term.getName())) {
sb.append(term.getName());
} else if ("@".equals(term.getName())) {
sb.append(term.getName());
break;
} else {
return -1;
}
}
if (sb.length() > 2) {
return j;
} else {
return -1;
}
}
示例2: getWeight
import org.ansj.domain.Term; //导入方法依赖的package包/类
private double getWeight(Term term, int length, int titleLength) {
if (term.getName().trim().length() < 2) {
return 0;
}
String pos = term.natrue().natureStr;
Double posScore = POS_SCORE.get(pos);
if (posScore == null) {
posScore = 1.0;
} else if (posScore == 0) {
return 0;
}
if (titleLength > term.getOffe()) {
return 5 * posScore;
}
return (length - term.getOffe()) * posScore / length;
}
示例3: getTwoTermFreq
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 获得两个term之间的频率
*
* @param fromTerm
* @param toTerm
* @return
*/
public static int getTwoTermFreq(Term fromTerm, Term toTerm) {
Nature from = fromTerm.natrue();
Nature to = toTerm.natrue();
if (from.index < 0 || to.index < 0) {
return 0;
}
return NATURETABLE[from.index][to.index];
}
示例4: computeArticleTfidf
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* @param content 正文
* @return
*/
private List<Keyword> computeArticleTfidf(String content, int titleLength) {
Map<String, Keyword> tm = new HashMap<String, Keyword>();
List<Term> parse = analysisType.parseStr(content).getTerms();
//FIXME: 这个依赖于用户自定义词典的词性,所以得需要另一个方法..
// parse = FilterModifWord.updateNature(parse) ;
for (Term term : parse) {
double weight = getWeight(term, content.length(), titleLength);
if (weight == 0)
continue;
Keyword keyword = tm.get(term.getName());
if (keyword == null) {
keyword = new Keyword(term.getName(), term.natrue().allFrequency, weight);
tm.put(term.getName(), keyword);
} else {
keyword.updateWeight(1);
}
}
TreeSet<Keyword> treeSet = new TreeSet<Keyword>(tm.values());
ArrayList<Keyword> arrayList = new ArrayList<Keyword>(treeSet);
if (treeSet.size() <= nKeyword) {
return arrayList;
} else {
return arrayList.subList(0, nKeyword);
}
}
示例5: getTwoTermFreq
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 获得两个term之间的频率
*
* @param fromTerm
* @param toTerm
* @return
*/
public static int getTwoTermFreq(Term fromTerm, Term toTerm) {
Nature from = fromTerm.natrue();
Nature to = toTerm.natrue();
if (from.index < 0 || to.index < 0) {
return 0;
}
return NATURETABLE[from.index][to.index];
}