获取主题或句子的关键字

Get the topics or the keywords of a sentence

大家早上好

你们有谁知道一个工具或一个 API 或以句子作为输入和输出的东西,它给出了这句话的主题或关键词?

我在在线演示中尝试了 TextRazor 它运行良好,就像您在屏幕截图中看到的那样 但是当我在 python 代码中用作库时,它总是给我一个空白列表,即使对于演示中使用的句子也是如此 这是我在 python:

中的代码
import textrazor
import ssl
textrazor.api_key ="bdd69bdc3f91045cdb6d4261d39df34d887278602cb8f60401b7eb0b"
client = textrazor.TextRazor(extractors=["entities", "topics"])
client.set_cleanup_mode("cleanHTML")
client.set_classifiers(["textrazor_newscodes"])
sentence = "Adam Hill,b It's Super Bowl Sunday  pastors. Get your Jesus Jukes ready! Guilt is an awesome motivator! #sarcasm"
response = client.analyze(sentence)
print(sentence)
print(len(response.topics()))
entities = list(response.entities())
print(len(entities))
for topic in response.topics():
    if topic.score > 0.3:
        print (topic.label)

实体和主题长度为零

有人建议我使用 OpenNlp,但我不知道如何提取主题和关键字如果你们中的任何人有任何教程或说明请帮助我

提前谢谢你

您必须删除行 client.set_cleanup_mode("cleanHTML")。那么它应该可以正常工作。

据我了解 cleanup_mode,它将您的文本视为 html。由于您的示例文本不是 html,因此它不会在 html 标签之间找到任何原始文本。