Appearance
Rewriter Open API V1
介绍
获取文本内容评估结果
- 暂不提供用户主动申请应用功能
- 如需开通文本评估开放api应用,请联系管理员
- 管理员开通应用后会通知 appId apiKey 等信息
- 如需冻结/打开应用,重置 apiKey,请联系管理员并提供app信息
- 通过 appId 与 apiKey 联合加密 sign = sha1(appId + "&" + appKey)
- 调用方法如下具体实现可见代码
- 示例代码下载:https://gitee.com/tmxmall/rewriter-openapi
Java示例
/**
* 加签
*/
String sign = sha1(appId + "&" + appKey);
String text = "Today I shed my old skin which hath, too long, suffered the bruises of failure and the wounds of mediority.Today I am born anew and my birthplace is a vineyard where there is fruit for all.Today I will pluck grapes of wisdom from the tallest and fullest vines in the vineyard,for these were planted by the wisest of my profession who have come before me,generation upon generation.Today I will savor the taste of grapes from these vines and verily I will swallow the seed of success buried in each and new life will sprout within me.";
JSONObject apiRequestBody = new JSONObject();
apiRequestBody.put("appId", appId);
apiRequestBody.put("sign", sign);
apiRequestBody.put("text", text);
String res = sendHttpPost(url, apiRequestBody.toString());
System.out.println(res);
JSONObject apiAssessReport = JSON.parseObject(res, JSONObject.class);
System.out.println(apiAssessReport);
- 响应结果展示
- 检验结果在传入的检测文本上标记
- 检测信息具体标记方式如下
{
"status": "success", // 响应状态
"errMsg": "", // 响应错误信息
"errCode": "10000", // 响应错误码
"response": {
// 检测结果集
"detectionResults": [
{
// 命中
"hits": [
{
// 命中全文本偏移量
"offset": 37,
// 命中长度
"len": 3,
// 替换词
"replacements": [
"for too"
],
// 命中内容
"hitContent": "too"
}
],
// 命中描述
"description": "这里可能有<v>动词及物-不及物错误</v>,请参考修改。",
// 例句
"exampleList": [
{
"rawExample": "The students arrived the residency in Houston.",
"modifiedExample": [
"The students arrived at the residency in Houston."
]
}
],
// 检测内容解释
"explanation": "英语中按动词后可否直接跟宾语,可把动词分成及物动词和不及物动词。所谓及物动词,就是谓语动词不必通过介词引荐宾语,可以直接跟宾语。相反的,不及物动词表示的动作没有对象,只是表示某种状态,不能直接带宾语。"
},
{
"hits": [
{
"offset": 107,
"len": 5,
"replacements": [
" Today"
],
"hitContent": "Today"
}
],
"description": "Missing space between sentences",
"exampleList": [],
"explanation": null
},
{
"hits": [
{
"offset": 189,
"len": 5,
"replacements": [
" Today"
],
"hitContent": "Today"
}
],
"description": "Missing space between sentences",
"exampleList": [],
"explanation": null
},
{
"hits": [
{
"offset": 275,
"len": 4,
"replacements": [
", for"
],
"hitContent": ",for"
}
],
"description": "Use of whitespace before comma and before/after parentheses",
"exampleList": [],
"explanation": null
},
{
"hits": [
{
"offset": 353,
"len": 11,
"replacements": [
", generation"
],
"hitContent": ",generation"
}
],
"description": "Use of whitespace before comma and before/after parentheses",
"exampleList": [],
"explanation": null
},
{
"hits": [
{
"offset": 381,
"len": 5,
"replacements": [
" Today"
],
"hitContent": "Today"
}
],
"description": "Missing space between sentences",
"exampleList": [],
"explanation": null
}
],
// 得分
"score": 62.3475,
// 花费时间 ms
"took": 1156
}
}
响应
field | type | comment |
---|---|---|
response | json | 评估结果 |
status | String | 请求状态 |
errMsg | String | 错误类型 |
errCode | String | 错误码 |
响应字段
field | comment |
---|---|
detectionResults | 文章检测结果 |
detectionResults.hits | 命中 |
detectionResults.hits.offset | 命中全文本偏移量 |
detectionResults.hits.len | 命中长度 |
detectionResults.hits.replacements | 替换词 |
detectionResults.hits.hitContent | 命中内容 |
detectionResults.description | 规则描述 |
detectionResults.exampleList | 例句 |
detectionResults.explanation | 检测内容解释 |
score | 得分 |
took | 花费时间 |
错误码
errCode | errMsg | status | comment |
---|---|---|---|
10000 | "" | success | 请求成功 |
10001 | system error | fail | 系统错误 |
10002 | sign fail | fail | 签名错误 |
10000 | invalid app | fail | 无效应用 |
10001 | frozen app | fail | 已冻结的应用 |
10002 | text too long over 5000 | fail | 文本超限 |