本文整理汇总了Java中org.ansj.domain.Term.getNext方法的典型用法代码示例。如果您正苦于以下问题:Java Term.getNext方法的具体用法?Java Term.getNext怎么用?Java Term.getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ansj.domain.Term
的用法示例。
在下文中一共展示了Term.getNext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResult
import org.ansj.domain.Term; //导入方法依赖的package包/类
@Override
protected List<Term> getResult(Graph graph) {
List<Term> result = new LinkedList<Term>();
int length = graph.terms.length - 1;
Term term = null;
for (int i = 0; i < length; i++) {
if ((term=graph.terms[i]) != null) {
result.add(term);
while((term =term.getNext())!=null){
result.add(term);
}
}
}
return result;
}
示例2: getMaxTerm
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 得道最到本行最大term
*
* @param i
* @return
*/
private Term getMaxTerm(int i) {
// TODO Auto-generated method stub
Term maxTerm = terms[i];
if (maxTerm == null) {
return null;
}
int maxTo = maxTerm.toValue();
Term term = maxTerm;
while ((term = term.getNext()) != null) {
if (maxTo < term.toValue()) {
maxTo = term.toValue();
maxTerm = term;
}
}
return maxTerm;
}
示例3: merger
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 具体的遍历打分方法
*
* @param i
* 起始位置
* @param j
* 起始属性
* @param to
*/
private void merger(Term fromTerm, int to) {
Term term = null;
if (terms[to] != null) {
term = terms[to];
while (term != null) {
// 关系式to.set(from)
term.setPathScore(fromTerm);
term = term.getNext();
}
} else {
char c = chars[to];
TermNatures tn = DATDictionary.getItem(c).termNatures;
if (tn == null || tn == TermNatures.NULL) {
tn = TermNatures.NULL;
}
terms[to] = new Term(String.valueOf(c), to, tn);
terms[to].setPathScore(fromTerm);
}
}
示例4: walkPathByScore
import org.ansj.domain.Term; //导入方法依赖的package包/类
public void walkPathByScore() {
Term term = null;
// BEGIN先行打分
mergerByScore(root, 0);
// 从第一个词开始往后打分
for (int i = 0; i < terms.length; i++) {
term = terms[i];
while (term != null && term.from() != null && term != end) {
int to = term.toValue();
mergerByScore(term, to);
term = term.getNext();
}
}
optimalRoot();
}
示例5: walkPath
import org.ansj.domain.Term; //导入方法依赖的package包/类
public void walkPath() {
Term term = null;
// BEGIN先行打分
merger(root, 0);
// 从第一个词开始往后打分
for (int i = 0; i < terms.length; i++) {
term = terms[i];
while (term != null && term.from() != null && term != end) {
int to = term.toValue();
merger(term, to);
term = term.getNext();
}
}
optimalRoot();
}
示例6: mergerByScore
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 根据分数
*
* @param i
* 起始位置
* @param j
* 起始属性
* @param to
*/
private void mergerByScore(Term fromTerm, int to) {
Term term = null;
if (terms[to] != null) {
term = terms[to];
while (term != null) {
// 关系式to.set(from)
term.setPathSelfScore(fromTerm);
term = term.getNext();
}
}
}
示例7: printGraph
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 对graph进行调试用的
*/
public void printGraph() {
for (Term term : terms) {
if (term == null) {
continue;
}
System.out.print(term.getName() + "\t" + term.selfScore() + " ,");
if ((term = term.getNext()) != null) {
System.out.print(term + "\t" + term.selfScore() + " ,");
}
System.out.println();
}
}
示例8: insertTerm
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 将一个term插入到链表中的对应位置中,应该是词长由大到小
*
* @param terms
* @param term
*/
public static void insertTerm(Term[] terms, Term term) {
Term temp = terms[term.getOffe()];
//插入到最右面
Term last = temp ;
while((temp = temp.getNext())!=null){
last = temp ;
}
last.setNext(term) ;
}
示例9: rmLittlePathByScore
import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
* 删除小节点。保证被删除的小节点的单个分数小于等于大节点的分数
*/
public void rmLittlePathByScore() {
int maxTo = -1;
Term temp = null;
for (int i = 0; i < terms.length; i++) {
if (terms[i] == null) {
continue;
}
Term maxTerm = null;
double maxScore = 0;
Term term = terms[i];
// 找到自身分数对大最长的
do {
if (maxTerm == null || maxScore > term.score()) {
maxTerm = term;
} else if (maxScore == term.score() && maxTerm.getName().length() < term.getName().length()) {
maxTerm = term;
}
} while ((term = term.getNext()) != null);
term = maxTerm;
do {
maxTo = term.toValue();
maxScore = term.score();
if (maxTo - i == 1 || i + 1 == terms.length)
continue;
boolean flag = true;// 可以删除
out: for (int j = i; j < maxTo; j++) {
temp = terms[j];
if (temp == null) {
continue;
}
do {
if (temp.toValue() > maxTo || temp.score() < maxScore) {
flag = false;
break out;
}
} while ((temp = temp.getNext()) != null);
}
// 验证通过可以删除了
if (flag) {
for (int j = i + 1; j < maxTo; j++) {
terms[j] = null;
}
}
} while ((term = term.getNext()) != null);
}
}