Babelfy API客户端
Babel的Python项目详细描述
pythonBabelFy实体标记符。可以用作库或命令行工具。与 Python2.7和Python3。
安装
pip install babelpy
或者克隆这个github存储库并运行python setup.py install,或者用sudo为 全局安装。
用法
将babelfy api密钥添加到配置文件或将其作为参数提供。
用作命令行工具
babelpy [-h] [-t | -tf ] [-e] [-ae] [-m] [-am] [-p] [-ex]
选项:
-h, --help show a help message and exit -key --api-key BabelFy API key -t --text text to be annotated by BabelFy API -tf --text-file path to the file containing the input text -e, --entities get entity data -ae --all-entities get entity and non-entity data -m --merged-entities get merged entities only -am --all-merged-entities get all merged entities -p --print dump all babelfy data to stdout -ex --export filename of the output file
示例:
babelpy -tf ~/data/fashion.txt -am -ex ~/data/fashion.json
有关帮助,请参见babelpy -h。
用作库
frombabelfyimportBabelfyClient# Instantiate BabelFy client.params=dict()params['lang']=LANGbabel_client=BabelfyClient(API_KEY,params)# Babelfy sentence.babel_client.babelfy(TEXT_TO_BE_BABELFIED)# Get entity data.print(babel_client.entities)# Get entity and non-entity data.print(babel_client.all_entities)# Get merged entities only.print(babel_client.merged_entities)# Get all merged entities.babel_client.all_merged_entities
使用python tests/run_tests.py
运行测试许可证
GNU-GPL 3.0