yige-python¶
Python library for yige. [中文](https://github.com/wwj718/yige-python/blob/master/readme.md)
<a href=”https://asciinema.org/a/7alk907q48i8evcgqdc09s9xu” target=”_blank”><img src=”https://asciinema.org/a/7alk907q48i8evcgqdc09s9xu.png” /></a>
- Free software: MIT license
- Documentation: https://yige-python.readthedocs.io.
Overview¶
The yige Python SDK makes it easy to use yige.ai
Features¶
- debug console
- text query
- entity manage
Installation¶
To install yige, simply:
$ pip install yige
or install it from repo:
$ pip install https://github.com/wwj718/yige-python.git
Usage¶
- debug console
>>> yige --console
...
- send text query
>>> CLIENT_ACCESS_TOKEN = '<YOUR_CLIENT_ACCESS_TOKEN>'
>>> ai = yige.Yige(CLIENT_ACCESS_TOKEN)
>>> request = ai.text_request()
>>> request.query = "我想买鞋"
>>> response = request.getresponse() #注意置信度 confidence
>>> print(response.json())
...
- post user entities
>>> DEV_ACCESS_TOKEN = '<YOUR_DEV_ACCESS_TOKEN>'
>>> ai = yige.Yige(DEV_ACCESS_TOKEN)
>>> payload= {}
>>> payload["name"] = "脚型" # 词库名称
>>> payload["type"] = 1 #是否定义同义词 1是 0否
>>> payload["automated_expansion"] = 0
>>> payload["entries"] = [] # 词库内容
>>> entity1 = {
"value": "正常内旋", # 同义词中比较权威的名称
"synonyms": [ # 同义词
"正常内旋",
"内旋正常",
"正常足弓",
"足弓正常"
]
}
>>> payload["entries"].append(entity1)
>>> user_entities_request = ai.user_entities_request()
>>> user_entities_request.user_entities = payload
>>> user_entities_response = user_entities_request.getresponse()
>>> print(user_entities_response.json())
...
Running examples¶
- Find examples from ‘examples’ path.
- Insert API key.
>>> CLIENT_ACCESS_TOKEN = '<YOUR_CLIENT_ACCESS_TOKEN>'
...
Test¶
make test
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.