Java Code Examples for com.hankcs.hanlp.HanLP#extractKeyword()

The following examples show how to use com.hankcs.hanlp.HanLP#extractKeyword() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Nlputil.java    From dk-fitting with Apache License 2.0 5 votes vote down vote up
/**
 * 关键词提取
 *
 * @param txt    要提取关键词的语句
 * @param keySum 要提取关键字的数量
 * @return 关键词列表
 */
public static String extractKeyword(String txt, int keySum){
    String keyString = "";
    if (txt == null || keySum <= 0){
        return String.valueOf(Collections.emptyList());
    }
    List<String> keyList = HanLP.extractKeyword(txt, keySum);
    for(String s : keyList){

        keyString = s +","+  keyString;
    }
    return keyString;
}
 
Example 2
Source File: KeywordServiceImpl.java    From onboard with Apache License 2.0 5 votes vote down vote up
@Override
public void generateOrUpdateKeywordsByIdentifiable(Recommendable identifiable) {
    deleteKeywordsByIdentifiable(identifiable);
    List<String> keywords = HanLP.extractKeyword(identifiable.generateText(), PER_IDENTIFIABLE_KEYWORD_COUNT);
    for (String keyword : keywords) {
        keywordMapper.insert(generateKeywordObjectByIdentifiableAndString(identifiable, keyword));
    }
}
 
Example 3
Source File: KeywordServiceImpl.java    From onboard with Apache License 2.0 4 votes vote down vote up
@Override
public List<String> getKeywordsByText(String text) {
    return HanLP.extractKeyword(text, PER_IDENTIFIABLE_KEYWORD_COUNT);
}
 
Example 4
Source File: DKNLPBase.java    From dk-fitting with Apache License 2.0 2 votes vote down vote up
/**
 * 关键词提取
 *
 * @param txt    要提取关键词的语句
 * @param keySum 要提取关键字的数量
 * @return 关键词列表
 */
public static List<String> extractKeyword(String txt, int keySum)
{
    if (txt == null || keySum <= 0) return Collections.emptyList();
    return HanLP.extractKeyword(txt, keySum);
}
 
Example 5
Source File: HANLPExtractor.java    From Gather-Platform with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 抽取关键词
 *
 * @param content 文章正文
 * @return 关键词列表
 */
public List<String> extractKeywords(String content) {
    return HanLP.extractKeyword(content, 10);
}
 
Example 6
Source File: HANLPExtractor.java    From spider with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 抽取关键词
 *
 * @param content 文章正文
 * @return 关键词列表
 */
public List<String> extractKeywords(String content) {
    return HanLP.extractKeyword(content, 10);
}