Reputation: 1912
Good morning all
Does anyone of you know a tool or an API or something that takes a sentence as input and as output, it gives the topics or keywords of this sentence?
I tried TextRazor in the online demo it works well like you can see in the screenshot
but when I used as a library in my python code it always gives me a blank list even for the sentence used in the demo
this is my code in 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)
It gives me zero for entities and topics length
Someone proposed for me to use OpenNlp but I didn't get how to extract topics and keywords if anyone of you has any tutorial or clarification please help me
And thank you in advance
Upvotes: 0
Views: 839
Reputation: 2694
You have to remove the line client.set_cleanup_mode("cleanHTML")
. Then it should work just fine.
As I understand the cleanup_mode, it treads your text as an html. As your example text is not html it won't find any raw text in between html tags.
Upvotes: 1