TextRank
声明:资源链接索引至第三方,平台不作任何存储,仅提供信息检索服务,若有版权问题,请https://help.coders100.com提交工单反馈
TextRank算法是一种用于提取文本中关键词的算法。它的基本思想是:对于每个词,计算其与其他词的相似度,然后根据相似度对词进行排序,得到一个关键词列表。
以下是一个简单的Java实现:
```java
import java.util.;
public class TextRank {
private static final int MAX_SAMPLES = 10;
private static final double MIN_SAMPLE_SIZE = 2;
private static final double MIN_DOUBLE = 0.5;
private static final double MAX_DOUBLE = 1.0;
public static void main(String[] args) {
String text = "这是一个关于计算机科学的有趣话题,包括人工智能、机器学习和深度学习等。";
System.out.println(getKeywords(text));
}
public static List getKeywords(String text) {
List keywords = new ArrayList();
int[] counts = new int[MAX_SAMPLES];
Map wordCounts = new HashMap();
for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if (ch == ' ') {
break;
}
if (!wordCounts.containsKey(ch)) {
wordCounts.put(ch, 1);
} else {
counts[wordCounts.get(ch)]++;
}
}
for (int i = 0; i < MAX_SAMPLES; i++) {
double sum = 0;
for (int j = 0; j < MAX_SAMPLES; j++) {
if (counts[j] > 0 && i != j) {
sum += Math.log((double) (1 - (double) (1 - counts[j])) (double) (1 + counts[j]));
}
}
if (sum >= MIN_DOUBLE && sum
以下是一个简单的Java实现:
```java
import java.util.;
public class TextRank {
private static final int MAX_SAMPLES = 10;
private static final double MIN_SAMPLE_SIZE = 2;
private static final double MIN_DOUBLE = 0.5;
private static final double MAX_DOUBLE = 1.0;
public static void main(String[] args) {
String text = "这是一个关于计算机科学的有趣话题,包括人工智能、机器学习和深度学习等。";
System.out.println(getKeywords(text));
}
public static List getKeywords(String text) {
List keywords = new ArrayList();
int[] counts = new int[MAX_SAMPLES];
Map wordCounts = new HashMap();
for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if (ch == ' ') {
break;
}
if (!wordCounts.containsKey(ch)) {
wordCounts.put(ch, 1);
} else {
counts[wordCounts.get(ch)]++;
}
}
for (int i = 0; i < MAX_SAMPLES; i++) {
double sum = 0;
for (int j = 0; j < MAX_SAMPLES; j++) {
if (counts[j] > 0 && i != j) {
sum += Math.log((double) (1 - (double) (1 - counts[j])) (double) (1 + counts[j]));
}
}
if (sum >= MIN_DOUBLE && sum
-
WebRtcNsAgcModel
- 2025-06-08 11:48:15访问
- 积分:1
-
Maven - 项目管理工具
- 2025-06-08 11:42:56访问
- 积分:1
-
trafficLight
- 2025-06-08 11:34:41访问
- 积分:1
-
TrafficGuard
- 2025-06-08 11:34:00访问
- 积分:1
-
MySimpleDB
- 2025-06-08 11:27:21访问
- 积分:1
-
SdColleague
- 2025-06-08 11:26:20访问
- 积分:1
-
Test
- 2025-06-08 11:16:57访问
- 积分:1
-
Phi_Test_calc
- 2025-06-08 11:16:16访问
- 积分:1
-
SpringBoot-DynamicDataSource
- 2025-06-08 11:12:18访问
- 积分:1
-
dbflute-fes-2014-demo
- 2025-06-08 11:08:30访问
- 积分:1
-
start.spring.io
- 2025-06-08 11:02:31访问
- 积分:1
-
start.spring.io
- 2025-06-08 11:02:06访问
- 积分:1
-
一些md文档
- 2025-06-08 10:58:43访问
- 积分:1
-
MD
- 2025-06-08 10:58:14访问
- 积分:1
-
TB_ShrV8.2
- 2025-06-08 10:50:37访问
- 积分:1
-
RTextView-master
- 2025-06-08 10:50:11访问
- 积分:1
-
DataX
- 2025-06-08 10:41:42访问
- 积分:1
-
ProcessDispatch
- 2025-06-08 10:34:45访问
- 积分:1
-
reggie-take-out
- 2025-06-08 10:26:12访问
- 积分:1
-
Wms物料仓储管理系统
- 2025-06-08 10:19:33访问
- 积分:1
-
PyThreadedTest
- 2025-06-08 10:10:53访问
- 积分:1
访问申明(访问视为同意此申明)
2.部分网络用户分享TXT文件内容为网盘地址有可能会失效(此类多为视频教程,如发生失效情况【联系客服】自助退回)
3.请多看看评论和内容介绍大数据情况下资源并不能保证每一条都是完美的资源
4.是否访问均为用户自主行为,本站只提供搜索服务不提供技术支持,感谢您的支持