总结一下:主要有2种提取方法
1. 关键词匹配
在一个已有的关键词库中匹配几个词语作为这篇文档的关键词。可用AC自动机算法等。
2. 关键词提取
通过算法分析,提取文档中一些词语作为关键词。可用tf-idf算法,textrank 算法等
一个简单的demo:
# -*- encoding=utf-8 -*-
from pyhanlp import *
sentence="关键词提取的几个方法"
result = HanLP.extractKeyword(sentence, 20)
print(result)
运行结果:
[关键词, 提取, 方法]
Process finished with exit code 0