1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| from lxml import etree
import textrazor
tree = etree.parse("wordlist.xml")
c=' '
for user in tree.xpath("/item/str",encoding="utf-8"):
c += user.text
print(c + '\n')
textrazor.api_key = "5522666"
client = textrazor.TextRazor(extractors=["word","entities", "topics","sentence","words"])
response = client.analyze(c)
def calcul(response):
cmd = ''
for entity in response.entities():
print(entity.id, entity.relevance_score, entity.confidence_score, entity.freebase_types)
cmd += str(entity.id) + str(entity.relevance_score) + str(entity.confidence_score) + str(entity.freebase_types) + '\n'
return str(cmd)
print(calcul(response)) |
Partager