用于python的官方tagme api包装器
tagme的Python项目详细描述
python的官方tagme api包装器。
安装和设置
这个库由pypi托管。您可以使用以下命令安装它:
pip install tagme
要访问TagmeAPI,您必须注册(免费!)在d4science平台上获得一个授权token。
- 注册到D4Science TagMe VRE。
- 登录后,单击左侧面板上的show按钮以获取授权令牌。
使用标记名
在对web服务进行任何调用之前,需要设置模块级的GCUBE_TOKEN变量。您可以使用:
importtagme# Set the authorization token for subsequent calls.tagme.GCUBE_TOKEN="<Your token goes here>"
作为设置模块变量的替代方法,可以在每次调用时使用可选的gcube_token参数传递令牌。
注释
注释服务允许您查找文本中提到的实体并将它们链接到维基百科。 这就是所谓的sa2kb问题。您可以使用以下内容对文本进行批注:
lunch_annotations=tagme.annotate("My favourite meal is Mexican burritos.")# Print annotations with a score higher than 0.1foranninlunch_annotations.get_annotations(0.1):printann
annotate方法接受参数来设置语言(参数lang,默认为en)和其他内容。 有关详细信息,请参见代码。 注释与表示注释正确的可能性的rho分数相关联。在这个例子中,我们放弃 分数低于0.1的批注。
提及查找
提到查找服务允许您查找文本中哪些部分可能是对某个实体的提及,而无需将它们链接到任何实体。
tomatoes_mentions=tagme.mentions("I definitely like ice cream better than tomatoes.")formentionintomatoes_mentions.mentions:printmention
mentions参数接受默认为en的可选语言参数lang。
变更日志
请参阅Changelog。