JCJC错别字检测系统API接口使用文档-添加黑名单、白名单词汇
1、地址前缀:http://IP:PORT/spellcheck/ 2、所有的接口调用:请使用 HTTP POST 方法,不支持 GET 方法 3、所有的接口调用:请使用 JSON POST 格式,不支持表单 FORM POST 的格式 4、字段:"content" 是需要提交的词语
对于 JCJC SaaS 版本的用户,地址前缀:
http://api.CuoBieZi.net/spellcheck/
对于 JCJC IaaS 版本的用户,地址前缀:
http://IP:8631/spellcheck/ IP 为私有化部署的服务器IP
添加白名单词汇:
http://IP:PORT/spellcheck/add_important_words
使用 JSON POST 的方法,不支持 Form POST 的方法。
如下代码所示:
# coding=utf8
import requests,json
#from jcjc_python_api import host_and_port
#from jcjc_python_api import print_host_and_port
def call_jcjc_add_one_words_api():
msg_str_content = "田春峰"
msg_str_content = "中华人民共和国"
payload = {
"content" : msg_str_content,
"mode": "advanced",
"username" : "tester",
"biz_type": "show",
}
host_and_port = "localhost:8631"
url = 'http://'+ host_and_port +'/spellcheck/add_important_words'
#print_host_and_port()
headers = {'content-type': 'application/json'}
print("====>call payload ==>",json.dumps(payload))
response = requests.post(url, data=json.dumps(payload), headers=headers)
print("status:", response.status_code , response.encoding)
returned_json_str=response.content
print("raw http return string:", returned_json_str.decode('utf8'))
print("if 乱码 please encoding : https://github.com/sunuslee/practical-python-utf8 ")
if __name__ == "__main__":
call_jcjc_add_one_words_api()
添加完成词汇后,可以使用查询接口,检查插入的结果:
http://IP:PORT/spellcheck/list_words 可以参考 上述代码 ,替换接口地址调用
添加敏感词、黑名单词汇的接口:
http://IP:PORT/spellcheck/add_sensitive_words 可以参考 上述代码 ,替换接口地址调用
另外:
1)目前只支持简体中文的字符,且字符之间不包含空格
2)不支持ASCII 字符的黑名单词汇、白名单词汇
3)添加词汇是实时生效的
4)添加词汇采用的异步机制,返回的状态为接口调用是否成功的状态,不一定保证存储到数据中
更详细的说明请参考 PDF API 接口文档:https://download.csdn.net/download/accesine960/17516787 。