1.textrazor
https://www.textrazor.com/ 去 这个的官方去注册,注册成功以后 https://www.textrazor.com/console 进入这个网址 可以看到这个就是api,但是免费的api只有一天500次的使用机会
python示例代码:
import textrazor
textrazor
.api_key
= "c3c38227a0e458e6095dce1e6ff54d4ae9e2584e91c9be8d26e132d3"
client
= textrazor
.TextRazor(extractors
=["entities", "topics"])
response
= client
.analyze("I like basketball, and I also like to sing.")
print(response
.topics())
for entity in response
.entities():
print(entity
.id
, entity
.relevance_score
, entity
.confidence_score
, entity
.freebase_types
)
结果展示
Basketball 0 1.49 ['/fictional_universe/fictional_organization_type', '/interests/interest', '/sports/school_sports_team', '/book/book_subject', '/cvg/computer_game_subject', '/organization/organization_sector', '/media_common/media_genre', '/broadcast/genre', '/sports/sports_team', '/interests/hobby', '/olympics/olympic_sport', '/cvg/cvg_genre', '/award/competition_type', '/award/award_discipline', '/film/film_subject', '/law/invention', '/media_common/netflix_genre', '/education/field_of_study', '/sports/sport']
可以看到 会对篮球这个实体进行分析,得到与篮球相关联的实体
上述是实体识别,不是分类
真正的api分类
https://www.paralleldots.com/api-wrappers
import paralleldots
# Setting your API key
paralleldots
.set_api_key("这里去官网去注册一下,一个月1000次")
# Get your API key here
# Viewing your API key
paralleldots
.get_api_key()
# Examples
text
= "Under the Uruguay Round, the national governments of all the member countries have negotiated improved access to the markets of the member countries so as to enable business enterprises to convert trade concessions into new business opportunities."
print(paralleldots
.taxonomy(text
))
结果展示:
{'taxonomy': [{'confidence_score': 0.6700183749, 'tag': 'WORLDPOST'}, {'confidence_score': 0.2379703969, 'tag': 'POLITICS'}, {'confidence_score': 0.0403302014, 'tag': 'BUSINESS'}]}
可以得到,属于哪一类