访问annif rest api的python客户端库
annif-client的Python项目详细描述
安宁客户
这是一个用于访问 Annif可用于自动主题的rest api 文本文档的索引和分类。
安装
最简单的安装方法是通过pip:
pip3 install annif-client
依赖关系
图书馆依赖于 requests使用的模块 用于http/rest访问。如果通过pip安装,依赖项将是 自动处理。
如何使用
客户端库附带了演示其用法的示例。你可以调用 运行annif_client.py脚本的示例。
在您自己的代码中,您可以像这样使用annifclient类:
from annif_client import AnnifClient
# then you can create your own client
annif = AnnifClient()
调用示例
下面是典型示例会话的输出:
$ python3 annif_client.py
Demonstrating usage of AnnifClient
* Creating an AnnifClient object
Now we have an AnnifClient object: AnnifClient(api_base='http://api.annif.org/v1/')
* Finding the available projects
Project id: yso-fi lang: fi name: YSO ensemble Finnish
Project id: yso-sv lang: sv name: YSO ensemble Swedish
Project id: yso-en lang: en name: YSO ensemble English
Project id: tfidf-fi lang: fi name: TF-IDF Finnish
Project id: tfidf-sv lang: sv name: TF-IDF Swedish
Project id: tfidf-en lang: en name: TF-IDF English
Project id: fasttext-fi lang: fi name: fastText Finnish
Project id: fasttext-sv lang: sv name: fastText Swedish
Project id: fasttext-en lang: en name: fastText English
Project id: maui-fi lang: fi name: Maui Finnish
Project id: maui-sv lang: sv name: Maui Swedish
Project id: maui-en lang: en name: Maui English
Project id: annif-api-fi lang: fi name: Annif prototype API Finnish
Project id: annif-api-sv lang: sv name: Annif prototype API Swedish
Project id: annif-api-en lang: en name: Annif prototype API English
Project id: ykl-fasttext-fi lang: fi name: YKL fastText Finnish
* Looking up information about a specific project
Project id: yso-en lang: en name: YSO ensemble English
* Analyzing a short text from a string
<http://www.yso.fi/onto/yso/p2228> 0.2595 red fox
<http://www.yso.fi/onto/yso/p5319> 0.2039 dog
<http://www.yso.fi/onto/yso/p8122> 0.1946 laziness
<http://www.yso.fi/onto/yso/p25726> 0.1285 brown
<http://www.yso.fi/onto/yso/p4760> 0.1220 triple jump
<http://www.yso.fi/onto/yso/p4758> 0.1194 long jump
<http://www.yso.fi/onto/yso/p2229> 0.1109 canines
<http://www.yso.fi/onto/yso/p10636> 0.1094 blue fox
<http://www.yso.fi/onto/yso/p4759> 0.1068 high jump
<http://www.yso.fi/onto/yso/p28336> 0.0911 animal training
* Analyzing a longer text from a file, with a limit on number of results
<http://www.yso.fi/onto/yso/p16495> 0.3651 licences (permits)
<http://www.yso.fi/onto/yso/p2346> 0.1656 copyright
<http://www.yso.fi/onto/yso/p11657> 0.1566 national libraries
<http://www.yso.fi/onto/yso/p6068> 0.1461 Apache
<http://www.yso.fi/onto/yso/p14833> 0.1220 copies
许可证
代码是在Apache 2.0许可证下发布的。