Skip to content
目录:

Rewriter Open API V2

介绍

获取文本内容检测结果与评估报告

  • 暂不提供用户主动申请应用功能
  • 如需开通文本评估开放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 resultRequire = "both";
        apiRequestBody.put("resultRequire", resultRequire);
        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
            }
        ],
        // 报告
        "report": {
            // 可读性评语
            "readabilityEvaluation": "可读性方面,用词、搭配和表达比较符合当前文体的风格,语言地道,行文逻辑非常连贯,表意明晰,语句几乎没有冗赘现象。词汇及语法方面,词汇的拼写和形式都很正确,语法的准确度高,标点符号使用得当。",
            // 可读性评分
            "readabilityScore": 82.45,
            // 综合得分
            "aggregateScore": 90.3475,
            // 用词恰当得分
            "wordScore": 76,
            // 文体得分
            "styleScore": 80,
            // 简洁分数
            "concisionScore": 87.5,
            // 衔接与连贯分数
            "logicScore": 83.333336,
            // 拼写得分
            "spellingScore": 100,
            // 语法得分
            "grammarScore": 100,
            // 拼写与语法得分
            "syntaxScore": 100,
            // 标点符号分数
            "punctuationScore": 100,
            // 切题得分 (暂不开放)
            "relevancyScore": 0,
            // 写作文体 (通用  暂不开放其他文体)
            "writingStyle": 2,
            // 词数
            "wordCount": 101,
            // 标点个数
            "punctCount": 8,
            // 字符数
            "charCount": 438,
            // 句子数
            "sentCount": 1,
            "took": 0
        },
        // 花费时间
        "took": 1836
    }
}

响应

fieldtypecomment
responsejson评估结果
statusString请求状态
errMsgString错误类型
errCodeString错误码

响应字段

fieldcomment
detectionResults文章检测结果
detectionResults.hits命中
detectionResults.hits.offset命中全文本偏移量
detectionResults.hits.len命中长度
detectionResults.hits.replacements替换词
detectionResults.hits.hitContent命中内容
detectionResults.description规则描述
detectionResults.exampleList例句
detectionResults.explanation检测内容解释
report报告
report.readabilityEvaluation可读性评语
report.readabilityScore可读性评分
report.aggregateScore综合得分
report.wordScore用词恰当得分
report.styleScore文体适宜得分
report.concisionScore简洁分数
report.logicScore衔接与连贯分数
report.spellingScore拼写得分
report.grammarScore语法得分
report.syntaxScore拼写和语法得分
report.punctuationScore标点符号分数
report.relevancyScore切题得分 (暂不开放)
report.writingStyle写作文体 (通用 暂不开放其他文体)
report.wordCount词数
report.punctCount标点数
report.charCount字符数
report.sentCount句子数
took花费时间

错误码

errCodeerrMsgstatuscomment
10000""success请求成功
10001system errorfail系统错误
10002sign failfail签名错误
10000invalid appfail无效应用
10001frozen appfail已冻结的应用
10002text too long over 5000fail文本超限