Skip to content

nlp-keyword based on segment.(基于分词的 NLP keyword 关键词) 支持关键词提取,自动摘要生成,文本相似度计算。

License

Notifications You must be signed in to change notification settings

houbb/nlp-keyword

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2a60c24 · Nov 1, 2024

History

8 Commits
Nov 1, 2024
Nov 1, 2024
Nov 1, 2024
Nov 1, 2024
Oct 31, 2024
Oct 31, 2024
Oct 31, 2024
Nov 1, 2024
Oct 31, 2024
Nov 1, 2024
Oct 31, 2024
Oct 31, 2024
Oct 31, 2024
Nov 1, 2024
Nov 1, 2024
Oct 31, 2024
Oct 31, 2024

Repository files navigation

nlp-keyword

nlp-keyword 高性能的 java 分词关键词提取实现,基于分词 segment

愿景:成为 java 最好用的关键词工具。

Build Status Maven Central Open Source Love

特性

  • 灵活的条件指定

  • 基于 TF-IDF 算法的关键字算法

  • 支持 auto-summary 自动摘要生成

  • 文本相似度计算支持

变更日志

关键词快速开始

maven 引入

<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>nlp-keyword-core</artifactId>
    <version>1.2.0</version>
</dependency>

快速开始

  • 获取关键词
final String text = "这是一个伸手不见五指的黑夜,夜太美。";

List<IKeywordResult> keywords =  KeywordHelper.keyword(text);
Assert.assertEquals("[伸手不见|0.86879235325, 太美|0.70848301840625, 伸手不见五指|0.63371734601875, 黑夜|0.509854654010625, 伸手|0.43563643037625]", keywords.toString());
  • 指定返回的个数
final String text = "这是一个伸手不见五指的黑夜,夜太美。";

List<IKeywordResult> keywords =  KeywordHelper.keyword(text, 1);
Assert.assertEquals("[伸手不见|0.86879235325]", keywords.toString());
  • 指定返回的格式
final String text = "这是一个伸手不见五指的黑夜,夜太美。";

List<String> keywords =  KeywordHelper.keyword(text, 1, KeywordResultHandlers.words());
Assert.assertEquals("[伸手不见]", keywords.toString());

自动摘要

maven 引入

<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>nlp-keyword-summary</artifactId>
    <version>1.2.0</version>
</dependency>

入门例子

final String text = "你好啊,我的老伙计。最近过得怎么样?我实在是觉得太久没有看见你了。听说北海的花开了,太久没去了。故事的最后会怎么样呢?我也不清楚。";

String summary = AutoSummaryHelper.autoSummary(text);

文本相似度

maven 引入

<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>nlp-keyword-similarity</artifactId>
    <version>1.2.0</version>
</dependency>

入门例子

final String source = "我喜欢看电影,读书和旅游。";
final String target = "我不喜欢看电影。我爱唱跳、RAP、Music~";

double rank = SimilarityHelper.similarity(source, target);

结果:

0.677537337470188

ROAD-MAP

  • [] 字典数据独立,便于用户自定义选择

  • 文本相似度

  • auto-summary 自动摘要

  • 完善文档+测试用例

About

nlp-keyword based on segment.(基于分词的 NLP keyword 关键词) 支持关键词提取,自动摘要生成,文本相似度计算。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published