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


Java Term.getName方法代码示例

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


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

示例1: splitWord

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 将一句话分词并封装成Subject对象
 * 
 * @param segment
 *      句子
 * @return
 *      主题对象
 */
public static Subject splitWord(String segment) {
    List<Term> parse = NlpAnalysis.parse(segment);
    Subject subject = new Subject();
    
    for (Term term : parse) {
        String name = term.getName();
        if (StringUtils.isEmpty(name) || name.equals(" ")) {
            continue;
        }
        
        if (term.getNatureStr().startsWith("n") || term.getNatureStr().equals("j")) {
            if (subject.getPredicate() == null || subject.getPredicate().size() == 0) {
                subject.addSubject(name);
            } else {
                subject.addObject(name);
            }
        } else if (term.getNatureStr().startsWith("v")) {
            subject.addPredicate(name);
        }
    }
    
    return subject;
}
 
开发者ID:William-Hai,项目名称:CorpusSpider,代码行数:32,代码来源:SubjectTools.java

示例2: incrementToken

import org.ansj.domain.Term; //导入方法依赖的package包/类
@Override
public boolean incrementToken() throws IOException {
	clearAttributes();
	
	Term term = analysis.next();
	
	//分词结束
	if (null == term) {
		end();
		return false;
	}
	
	String name = term.getName();
	int length = name.length();
       
	termAtt.copyBuffer(name.toCharArray(), 0, length);
	offsetAtt.setOffset(term.getOffe(), term.getOffe()+length);
	
	return true;
}
 
开发者ID:flash0729,项目名称:ansj-seg-for-lucene3,代码行数:21,代码来源:AnsjTokenizer.java

示例3: cutLine

import org.ansj.domain.Term; //导入方法依赖的package包/类
String cutLine(String line){
    List<Term> Terms = NlpAnalysis.parse(line);
    String result = "";
    for(Term t : Terms){
        if(stopWords.contains(t.getName())) continue;
        result += t.getName() + " ";
    }
    return result;
}
 
开发者ID:IACASNLPIR,项目名称:GKHMC,代码行数:10,代码来源:BuildHistoryTimelineIndex.java

示例4: containKeyword

import org.ansj.domain.Term; //导入方法依赖的package包/类
public static boolean containKeyword(String text,String keyword) throws Exception{
	 boolean flag=false;
	 List<Term> tokens=ToAnalysis.parse(keyword);
	 for(Term t:tokens){
			String token=t.getName();
			if(text.contains(token)){
				flag=true;
				break;
			}
	}		
	 return flag;
}
 
开发者ID:YufangWoo,项目名称:news-crawler,代码行数:13,代码来源:HtmlContentExtractor.java

示例5: termStatus

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 传入一个term 返回这个term的状态
 * 
 * @param branch
 * @param term
 * @return
 */
private WoodInterface termStatus(WoodInterface branch, Term term) {
	String name = term.getName();
	for (int j = 0; j < name.length(); j++) {
		branch = branch.get(name.charAt(j));
		if (branch == null) {
			return null;
		}
	}
	return branch;
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:18,代码来源:UserDefineRecognition.java

示例6: recognition

import org.ansj.domain.Term; //导入方法依赖的package包/类
public void recognition() {
	String name = null;
	Term term = null;
	reset();
	for (int i = 0; i < terms.length; i++) {
		if (terms[i] == null) {
			continue;
		}

		term = terms[i];
		// 如果名字的开始是人名的前缀,或者后缀.那么忽略
		if (tempList.size() == 0) {
			if (term.termNatures().personAttr.end > 10) {
				continue;
			}

			if ((terms[i].getName().length() == 1 && ISNOTFIRST.contains(terms[i].getName().charAt(0)))) {
				continue;
			}
		}

		name = term.getName();

		if (term.termNatures() == TermNatures.NR || term.termNatures() == TermNatures.NW || name.length() == 1) {
			boolean flag = validate(name);
			if (flag) {
				tempList.add(term);
			}
		} else if (tempList.size() == 1) {
			reset();
		} else if (tempList.size() > 1) {
			TermUtil.insertTerm(terms, tempList, TermNatures.NR);
			reset();
		}
	}
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:37,代码来源:ForeignPersonRecognition.java

示例7: getNewTerms

import org.ansj.domain.Term; //导入方法依赖的package包/类
public List<Term> getNewTerms() {
	LinkedList<Term> result = new LinkedList<Term>();
	String name = null;
	Term term = null;
	reset();
	for (int i = 0; i < terms.length; i++) {
		if (terms[i] == null) {
			continue;
		}

		term = terms[i];
		// 如果名字的开始是人名的前缀,或者后缀.那么忽略
		if (tempList.size() == 0) {
			if (term.termNatures().personAttr.end > 10) {
				continue;
			}

			if ((terms[i].getName().length() == 1 && ISNOTFIRST.contains(terms[i].getName().charAt(0)))) {
				continue;
			}
		}

		name = term.getName();

		if (term.termNatures() == TermNatures.NR || term.termNatures() == TermNatures.NW || name.length() == 1) {
			boolean flag = validate(name);
			if (flag) {
				tempList.add(term);
			}
		} else if (tempList.size() == 1) {
			reset();
		} else if (tempList.size() > 1) {
			result.add(makeNewTerm());
			reset();
		}
	}
	return result;
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:39,代码来源:ForeignPersonRecognition.java

示例8: incrementToken

import org.ansj.domain.Term; //导入方法依赖的package包/类
@Override
public boolean incrementToken() throws IOException {
	// TODO Auto-generated method stub
	clearAttributes();
	int position = 0;
	Term term = null;
	String name = null;
	int length = 0;
	boolean flag = true;
	do {
		term = analysis.next();
		if (term == null) {
			break;
		}
		name = term.getName();
		length = name.length();
		if (isStemming && term.termNatures() == TermNatures.EN) {
			name = stemmer.stem(name);
			term.setName(name);
		}

		if (filter != null && filter.contains(name)) {
			continue;
		} else {
			position++;
			flag = false;
		}
	} while (flag);

	if (term != null) {
		positionAttr.setPositionIncrement(position);
		termAtt.setEmpty().append(term.getName());
		offsetAtt.setOffset(term.getOffe(), term.getOffe() + length);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:39,代码来源:AnsjTokenizer.java

示例9: makeNewTermNum

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 将两个term合并为一个全新的term
 * 
 * @param termNatures
 * @return
 */
public static Term makeNewTermNum(Term from, Term to, TermNatures termNatures) {
	Term term = new Term(from.getName() + to.getName(), from.getOffe(), termNatures);
	term.termNatures().numAttr = from.termNatures().numAttr;
	TermUtil.termLink(term, to.to());
	TermUtil.termLink(term.from(), term);
	return term;
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:14,代码来源:TermUtil.java

示例10: parseNature

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 得到细颗粒度的分词,并且确定词性
 * 
 * @return 返回是null说明已经是最细颗粒度
 */
public static void parseNature(Term term) {
	if (!Nature.NW.equals(term.natrue())) {
		return;
	}

	String name = term.getName();

	if (name.length() <= 3) {
		return;
	}

	// 是否是外国人名
	if (ForeignPersonRecognition.isFName(name)) {
		term.setNature(NatureLibrary.getNature("nrf"));
		return;
	}

	List<Term> subTerm = term.getSubTerm();

	// 判断是否是机构名
	term.setSubTerm(subTerm);
	Term first = subTerm.get(0);
	Term last = subTerm.get(subTerm.size() - 1);
	int[] is = companyMap.get(first.getName());
	int all = 0;

	is = companyMap.get(last.getName());
	if (is != null) {
		all += is[1];
	}

	if (all > 1000) {
		term.setNature(NatureLibrary.getNature("nt"));
		return;
	}
}
 
开发者ID:Lewis-Liu-001,项目名称:ansj_segx,代码行数:42,代码来源:TermUtil.java

示例11: termStatus

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 传入一个term 返回这个term的状态
 * 
 * @param branch
 * @param term
 * @return
 */
private SmartForest<String[]> termStatus(SmartForest<String[]> branch, Term term) {
    String name = term.getName();
    SmartForest<String[]> sf = branch;
    for (int j = 0; j < name.length(); j++) {
        sf = sf.get(name.charAt(j));
        if (sf == null) {
            return null;
        }
    }
    return sf;
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:19,代码来源:UserDefineRecognition.java

示例12: recognition

import org.ansj.domain.Term; //导入方法依赖的package包/类
@Override
public void recognition(Term[] terms) {
    this.terms = terms;
    String name = null;
    Term term = null;
    reset();
    for (int i = 0; i < terms.length; i++) {
        if (terms[i] == null) {
            continue;
        }

        term = terms[i];
        // 如果名字的开始是人名的前缀,或者后缀.那么忽略
        if (tempList.isEmpty()) {
            if (term.termNatures().personAttr.end > 10) {
                continue;
            }

            if ((terms[i].getName().length() == 1 && ISNOTFIRST.contains(terms[i].getName().charAt(0)))) {
                continue;
            }
        }

        name = term.getName();

        if (term.termNatures() == TermNatures.NR || term.termNatures() == TermNatures.NW || name.length() == 1) {
            boolean flag = validate(name);
            if (flag) {
                tempList.add(term);
            }
        } else if (tempList.size() == 1) {
            reset();
        } else if (tempList.size() > 1) {
            TermUtil.insertTerm(terms, tempList, TermNatures.NR);
            reset();
        }
    }
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:39,代码来源:ForeignPersonRecognition.java

示例13: getNewTerms

import org.ansj.domain.Term; //导入方法依赖的package包/类
public List<Term> getNewTerms() {
    LinkedList<Term> result = new LinkedList<Term>();
    String name = null;
    Term term = null;
    reset();
    for (int i = 0; i < terms.length; i++) {
        if (terms[i] == null) {
            continue;
        }

        term = terms[i];
        // 如果名字的开始是人名的前缀,或者后缀.那么忽略
        if (tempList.isEmpty()) {
            if (term.termNatures().personAttr.end > 10) {
                continue;
            }

            if ((terms[i].getName().length() == 1 && ISNOTFIRST.contains(terms[i].getName().charAt(0)))) {
                continue;
            }
        }

        name = term.getName();

        if (term.termNatures() == TermNatures.NR || term.termNatures() == TermNatures.NW || name.length() == 1) {
            boolean flag = validate(name);
            if (flag) {
                tempList.add(term);
            }
        } else if (tempList.size() == 1) {
            reset();
        } else if (tempList.size() > 1) {
            result.add(makeNewTerm());
            reset();
        }
    }
    return result;
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:39,代码来源:ForeignPersonRecognition.java

示例14: 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);
    }

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

示例15: makeNewTermNum

import org.ansj.domain.Term; //导入方法依赖的package包/类
/**
 * 将两个term合并为一个全新的term
 * 
 * @param termNatures
 * @return
 */
public static Term makeNewTermNum(Term from, Term to, TermNatures termNatures) {
    Term term = new Term(from.getName() + to.getName(), from.getOffe(), termNatures);
    term.termNatures().numAttr = from.termNatures().numAttr;
    TermUtil.termLink(term, to.to());
    TermUtil.termLink(term.from(), term);
    return term;
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:14,代码来源:TermUtil.java


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