当前位置: 首页>>代码示例>>Java>>正文


Java Term.toValue方法代码示例

本文整理汇总了Java中org.ansj.domain.Term.toValue方法的典型用法代码示例。如果您正苦于以下问题:Java Term.toValue方法的具体用法?Java Term.toValue怎么用?Java Term.toValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ansj.domain.Term的用法示例。


在下文中一共展示了Term.toValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:23,代码来源:Graph.java

示例2: rmLittleSinglePath

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 删除无意义的节点,防止viterbi太多
 */
public void rmLittleSinglePath() {
	int maxTo = -1;
	Term temp = null;
	for (int i = 0; i < terms.length; i++) {
		if (terms[i] == null)
			continue;
		maxTo = terms[i].toValue();
		if (maxTo - i == 1 || i + 1 == terms.length)
			continue;
		for (int j = i; j < maxTo; j++) {
			temp = terms[j];
			if (temp != null && temp.toValue() <= maxTo && temp.getName().length() == 1) {
				terms[j] = null;
			}
		}
	}
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:21,代码来源:Graph.java

示例3: rmLittleSinglePath

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 删除无意义的节点,防止viterbi太多
 */
public void rmLittleSinglePath() {
    int maxTo = -1;
    Term temp = null;
    for (int i = 0; i < terms.length; i++) {
        if (terms[i] == null)
            continue;
        maxTo = terms[i].toValue();
        if (maxTo - i == 1 || i + 1 == terms.length)
            continue;
        for (int j = i; j < maxTo; j++) {
            temp = terms[j];
            if (temp != null && temp.toValue() <= maxTo && temp.getName().length() == 1) {
                terms[j] = null;
            }
        }
    }
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:21,代码来源:Graph.java

示例4: walkPath

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 干涉性增加相对权重
 * 
 * @param relationMap
 */
public void walkPath(Map<String, Double> relationMap) {
    Term term = null;
    // BEGIN先行打分
    merger(root, 0, relationMap);
    // 从第一个词开始往后打分
    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, relationMap);
            term = term.next();
        }
    }
    optimalRoot();
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:21,代码来源:Graph.java

示例5: recogntion_

import org.ansj.domain.Term; //导入方法依赖的package包/类
private List<Term> recogntion_() {
	Term term = null;
	Term tempTerm = null;
	List<Term> termList = new ArrayList<Term>();
	int beginFreq = 10;
	for (int i = 0; i < terms.length; i++) {
		term = terms[i];
		if (term == null || !term.termNatures().personAttr.flag) {
			continue;
		}
		term.score(0);
		term.selfScore(0);
		int freq = 0;
		for (int j = 2; j > -1; j--) {
			freq = term.termNatures().personAttr.getFreq(j, 0);
			if ((freq > 10) || (term.getName().length() == 2 && freq > 10)) {
				tempTerm = nameFind(i, beginFreq, j);
				if (tempTerm != null) {
					termList.add(tempTerm);
					// 如果是无争议性识别
					if (skip) {
						for (int j2 = i; j2 < tempTerm.toValue(); j2++) {
							if (terms[j2] != null) {
								terms[j2].score(0);
								terms[j2].selfScore(0);
							}
						}
						i = tempTerm.toValue() - 1;
						break;
					}
				}
			}
		}
		beginFreq = term.termNatures().personAttr.begin + 1;
	}
	return termList;
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:38,代码来源:AsianPersonRecognition.java

示例6: 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();
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:16,代码来源:Graph.java

示例7: 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();
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:16,代码来源:Graph.java

示例8: 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.next();
        }
    }
    optimalRoot();
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:16,代码来源:Graph.java

示例9: rmLittlePath

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 删除最短的节点
 */
public void rmLittlePath() {
	int maxTo = -1;
	Term temp = null;
	Term maxTerm = null;
	// 是否有交叉
	boolean flag = false;
	int length = terms.length - 1;
	for (int i = 0; i < length; i++) {
		maxTerm = getMaxTerm(i);

		if (maxTerm == null)
			continue;

		maxTo = maxTerm.toValue();

		/**
		 * 对字数进行优化.如果一个字.就跳过..两个字.且第二个为null则.也跳过.从第二个后开始
		 */
		switch (maxTerm.getName().length()) {
		case 1:
			continue;
		case 2:
			if (terms[i + 1] == null) {
				i = i + 1;
				continue;
			}
		}

		/**
		 * 判断是否有交叉
		 */
		for (int j = i + 1; j < maxTo; j++) {
			temp = getMaxTerm(j);
			if (temp == null) {
				continue;
			}
			if (maxTo < temp.toValue()) {
				maxTo = temp.toValue();
				flag = true;
			}
		}

		if (flag) {
			i = maxTo - 1;
			flag = false;
		} else {
			maxTerm.setNext(null);
			terms[i] = maxTerm;
			for (int j = i + 1; j < maxTo; j++) {
				terms[j] = null;
			}
			// FIXME: 这里理论上得设置。但是跑了这么久,还不发生错误。应该是不依赖于双向链接。需要确认下。这段代码是否有用
			// //将下面的to的from设置回来
			// temp = terms[i+maxTerm.getName().length()] ;
			// do{
			// temp.setFrom(maxTerm) ;
			// }while((temp=temp.getNext())!=null) ;

		}
	}
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:65,代码来源:Graph.java

示例10: 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);
	}
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:52,代码来源:Graph.java

示例11: rmLittlePath

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 删除最短的节点
 */
public void rmLittlePath() {
    int maxTo = -1;
    Term temp = null;
    Term maxTerm = null;
    // 是否有交叉
    boolean flag = false;
    final int length = terms.length - 1;
    for (int i = 0; i < length; i++) {
        maxTerm = getMaxTerm(i);
        if (maxTerm == null)
            continue;

        maxTo = maxTerm.toValue();

        /**
         * 对字数进行优化.如果一个字.就跳过..两个字.且第二个为null则.也跳过.从第二个后开始
         */
        switch (maxTerm.getName().length()) {
            case 1:
                continue;
            case 2:
                if (terms[i + 1] == null) {
                    i = i + 1;
                    continue;
                }
        }

        /**
         * 判断是否有交叉
         */
        for (int j = i + 1; j < maxTo; j++) {
            temp = getMaxTerm(j);
            if (temp == null) {
                continue;
            }
            if (maxTo < temp.toValue()) {
                maxTo = temp.toValue();
                flag = true;
            }
        }

        if (flag) {
            i = maxTo - 1;
            flag = false;
        } else {
            maxTerm.setNext(null);
            terms[i] = maxTerm;
            for (int j = i + 1; j < maxTo; j++) {
                terms[j] = null;
            }
            // FIXME: 这里理论上得设置。但是跑了这么久,还不发生错误。应该是不依赖于双向链接。需要确认下。这段代码是否有用
            // //将下面的to的from设置回来
            // temp = terms[i+maxTerm.getName().length()] ;
            // do{
            // temp.setFrom(maxTerm) ;
            // }while((temp=temp.next())!=null) ;

        }
    }
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:64,代码来源:Graph.java

示例12: 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.next()) != 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.next()) != null);
            }
            // 验证通过可以删除了
            if (flag) {
                for (int j = i + 1; j < maxTo; j++) {
                    terms[j] = null;
                }
            }
        } while ((term = term.next()) != null);
    }
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:52,代码来源:Graph.java


注:本文中的org.ansj.domain.Term.toValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。