Skip to content

wps合作API V2

文档更新时间说明
12月13日 15时补充说明 提示接口 xclozeType xchunkType 类型说明
12月18日 17时更新说明 错误的类别汉化、建议
12月25日 14时增加三合一接口,错误增加了一对多的cands
12月25日 16时新增tip中的xconfusion 说明

一、总概

鉴权

使用 IP白名单 作为鉴权方式

shell
curl --request POST \
  --url https://url_cn/api \
  -H "Content-Type: application/json" \
  --data '{"json":"数据"}'
curl --request POST \
  --url https://url_cn/api \
  -H "Content-Type: application/json" \
  --data '{"json":"数据"}'

约定

  • 使用 IP白名单 鉴权
  • 提交的数据json 放在body中
  • 返回体 也是以JSON 格式给出

流程

  • 1、文章分句
  • 2、分句后可并行获取错误、警告、提示

环境

url_cn 环境 入口

域名类型说明
http://wps.pigai.org:8756string正式环境

二、文章分句接口

接口 POST https://url_cn/wpsv2-xtext

数据

json
{
    "text": "She has ready.\nI pay attention to the box. This are gramamtical sentence."
}
{
    "text": "She has ready.\nI pay attention to the box. This are gramamtical sentence."
}
名称类型必填说明
textstring文本

返回

json
{
	"snts": [
		"She has ready.",
		"\nI pay attention to the box.",
		"This are gramamtical sentence."
	],
	"offsets": [0, 14, 43 ]
}
{
	"snts": [
		"She has ready.",
		"\nI pay attention to the box.",
		"This are gramamtical sentence."
	],
	"offsets": [0, 14, 43 ]
}
名称类型必填说明
sntsstring[]分句后的句子
offsetsnumber[]分句后的偏移

三、错误接口

接口 POST https://url_cn/wpsv2-err

数据

json
{
    "snts": [
    "She has ready.\n",
    "I pay attention to the box.",
    "This are gramamtical sentence."
  ]
}
{
    "snts": [
    "She has ready.\n",
    "I pay attention to the box.",
    "This are gramamtical sentence."
  ]
}
名称类型必填说明
sntsstring[]分句后的句子

返回

json
{
    "data": [
        {
            "snt": "She has ready.\n",
            "edits": [
                {
                    "offset": 4,
                    "itok": 1,
                    "orig": "has",
                    "corr": "is",
                    "type": "R",
                    "cate": "VERB"
                }
            ],
            "toks": [
                {
                    "i": 0,
                    "offset": 0,
                    "textws": "She "
                },
                {
                    "i": 1,
                    "offset": 4,
                    "textws": "has "
                },
                {
                    "i": 2,
                    "offset": 8,
                    "textws": "ready"
                },
                {
                    "i": 3,
                    "offset": 13,
                    "textws": "."
                },
                {
                    "i": 4,
                    "offset": 14,
                    "textws": "\n"
                }
            ]
        }
        ,{}
    ],
    "total": 4
}
{
    "data": [
        {
            "snt": "She has ready.\n",
            "edits": [
                {
                    "offset": 4,
                    "itok": 1,
                    "orig": "has",
                    "corr": "is",
                    "type": "R",
                    "cate": "VERB"
                }
            ],
            "toks": [
                {
                    "i": 0,
                    "offset": 0,
                    "textws": "She "
                },
                {
                    "i": 1,
                    "offset": 4,
                    "textws": "has "
                },
                {
                    "i": 2,
                    "offset": 8,
                    "textws": "ready"
                },
                {
                    "i": 3,
                    "offset": 13,
                    "textws": "."
                },
                {
                    "i": 4,
                    "offset": 14,
                    "textws": "\n"
                }
            ]
        }
        ,{}
    ],
    "total": 4
}
名称类型必填说明
dataobject[]分句后的句子
totalnumber错误总数
  • data下是一个的数据对象其中一个样例
  • edits修改方案中itok是词汇在toks中的位置 这样就能替换了
名称类型必填说明
sntstring本句的句子文本
editsobject[]修改提方案
edits[i].offsetnumber句子中字符串的偏移
edits[i].itoknumber句子中字词汇的偏移 内容在toks中
edits[i].origstring分句后的句子
edits[i].corrstring分句后的句子
edits[i].typeR,M,UR替换 M新增 U删除
edits[i].catestring错误类别
edits[i].ofstring错误类别汉化
edits[i].shortmsgstring建议
toksobject[]词汇位置
toksp[i].inumber句子内按词算的位置
toksp[i].offsetnumber句子内字符串的位置
toksp[i].textwsnumber词汇
ts
export interface editType{  
    "offset": number
    "itok": number //toks中的开始的位置
    "iend": number //toks中的结束前的位置
    "orig": string
    "corr":string
    "type": "R"|"M"|"U" //R替换 M新增 U删除
    "cate":string
    "of"?:string //类别汉化
    "shortmsg":string //建议
    isModify?:boolean  //是否修改 修改接替换 这个属性需要自己添加
    cands?:string[]  //可替换的选项 选项多的时候放这个字段
    context?:any[] //替换词汇 下标0|1 都是 number 2 string
}
export interface editType{  
    "offset": number
    "itok": number //toks中的开始的位置
    "iend": number //toks中的结束前的位置
    "orig": string
    "corr":string
    "type": "R"|"M"|"U" //R替换 M新增 U删除
    "cate":string
    "of"?:string //类别汉化
    "shortmsg":string //建议
    isModify?:boolean  //是否修改 修改接替换 这个属性需要自己添加
    cands?:string[]  //可替换的选项 选项多的时候放这个字段
    context?:any[] //替换词汇 下标0|1 都是 number 2 string
}

四、警告接口

  • 接口 POST https://url_cn/wpsv2-warn
  • url的 names 有两个值 xsntwarn 和 xsntflue 中间是用逗号分开 names=urlencode(xsntwarn,xsntflue);
  • 后续有增加错误类型 会加 names 上到这儿来,缺省可以不写

数据

json
{
    "snts": [
    "She has ready.\n",
    "I pay attention to the box.",
    "This are gramamtical sentence."
  ]
}
{
    "snts": [
    "She has ready.\n",
    "I pay attention to the box.",
    "This are gramamtical sentence."
  ]
}
名称类型必填说明
sntsstring[]分句后的句子

返回

json
{
  "total": 5,
  "items": {
    "xsntwarn": 2,
    "xsntflue": 3
  },
  "data": {
    "xsntwarn": [
      [],
      [
        {
          "type": "NP",
          "offset": 6,
          "wordlist": "a big boxe",
          "shortmsg": "<b>a big boxe</b> 在本族语中很少使用",
          "by": "gramoov"
        }
      ],
      [
        {
          "type": "word",
          "pos": "NOUN",
          "ibeg": 2,
          "offset": 7,
          "wordlist": "traffics",
          "shortmsg": "<b>traffics</b> 一般不用复数形式",
          "by": "noun_noplual"
        }
      ]
    ],
    "xsntflue": [
      [
        {
          "type": "sent",
          "snt": "She has ready.",
          "flue": 0.056,
          "by": "xsntflue",
          "shortmsg": "请检查本句句法"
        }
      ],
      [
        {
          "type": "sent",
          "snt": "It is a big boxe.",
          "flue": 0.4247,
          "by": "xsntflue",
          "shortmsg": "请检查本句句法"
        }
      ],
      [
        {
          "type": "sent",
          "snt": "It are traffics.",
          "flue": 0.0425,
          "by": "xsntflue",
          "shortmsg": "请检查本句句法"
        }
      ]
    ]
  }
}
{
  "total": 5,
  "items": {
    "xsntwarn": 2,
    "xsntflue": 3
  },
  "data": {
    "xsntwarn": [
      [],
      [
        {
          "type": "NP",
          "offset": 6,
          "wordlist": "a big boxe",
          "shortmsg": "<b>a big boxe</b> 在本族语中很少使用",
          "by": "gramoov"
        }
      ],
      [
        {
          "type": "word",
          "pos": "NOUN",
          "ibeg": 2,
          "offset": 7,
          "wordlist": "traffics",
          "shortmsg": "<b>traffics</b> 一般不用复数形式",
          "by": "noun_noplual"
        }
      ]
    ],
    "xsntflue": [
      [
        {
          "type": "sent",
          "snt": "She has ready.",
          "flue": 0.056,
          "by": "xsntflue",
          "shortmsg": "请检查本句句法"
        }
      ],
      [
        {
          "type": "sent",
          "snt": "It is a big boxe.",
          "flue": 0.4247,
          "by": "xsntflue",
          "shortmsg": "请检查本句句法"
        }
      ],
      [
        {
          "type": "sent",
          "snt": "It are traffics.",
          "flue": 0.0425,
          "by": "xsntflue",
          "shortmsg": "请检查本句句法"
        }
      ]
    ]
  }
}
名称类型必填说明
totalnumber警告总数
itemsobject分类总数
dataobject警告数据
  • data 下有 xsntwarn 表示句子层的警告 和 xsntflue 表示语法警告
  • xsntwarnxsntflue 都是 key-Object 对, 直接显示 key 为警告部分
  1. type: 类型, 2. wordlist : 当前的匹配词或词组 3. shortmsg: 提示信息 4. by: 引擎模块名称
ts
interface xsntwarnType {
   "type": string //类型
    "offset"?:  number
    "wordlist": string //当前的匹配词或词组
    "shortmsg":string // 提示信息
    "by": string //引擎模块名称
}
interface xsntwarnType {
   "type": string //类型
    "offset"?:  number
    "wordlist": string //当前的匹配词或词组
    "shortmsg":string // 提示信息
    "by": string //引擎模块名称
}
ts
interface xsntflueType {
   "type": string //类型
    "snt": string //句子,
    "flue": number //句子流畅度评分  
    "by"?: string // 引擎模块名称 "xsntflue",
    "shortmsg": string // 建议 "请检查本句句法"
}
interface xsntflueType {
   "type": string //类型
    "snt": string //句子,
    "flue": number //句子流畅度评分  
    "by"?: string // 引擎模块名称 "xsntflue",
    "shortmsg": string // 建议 "请检查本句句法"
}

五、提示接口

  • 接口 POST https://url_cn/wpsv2-tip
  • url的 names 有两个值 xcloze 和 xchunk 中间是用逗号分开 names=urlencode(xcloze,xchunk);
  • 后续有增加错误类型 会加 names 上到这儿来,缺省可以不写

数据

json
{
  "snts": [
    "I am too tired to move on.",
    "I pay attention to the box."
  ],
  "topk": 10
}
{
  "snts": [
    "I am too tired to move on.",
    "I pay attention to the box."
  ],
  "topk": 10
}
名称类型必填说明
sntsstring[]分句后的句子
topknumber建议提示个数

返回

json
{
  "total": 4,
  "items": {
    "xcloze": 2,
    "xchunk": 2
  },
  "data": {
    "xcloze": [
      [
        {
          "word": "tired",
          "sentiment": 0,
          "cands": [
            [
              "weak", //可替换的词
              0.0283, //weak 在 I am too tired/weak to move on. 的关联
              0.2589 //weak 与 tired 词性的关联距离
            ],
            [
              "hungry",
              0.0134,
              0.4132
            ]
          ]
        }
      ],
      [
        {
          "word": "box",
          "sentiment": 0,
          "cands": [
            [
              "clock",
              0.0438,
              0.0791
            ],
            [
              "surroundings",
              0.0142,
              0.0502
            ],
            [
              "noise",
              0.0135,
              0.0323
            ],[]
          ]
        }
      ]
    ],
    "xchunk": [
      [],
      [
        {
          "ibeg": 1,
          "iend": 4,
          "tag": "_jj",
          "offset": 1,
          "pattern": "pay _jj attention to",
          "cands": [
            [
              "close",
              "195392"
            ],
            [
              "particular",
              "159440"
            ],[]
            
          ]
        },
        {
          "ibeg": 4,
          "iend": 6,
          "tag": "_jj",
          "offset": 1,
          "pattern": "the _jj box",
          "cands": [
            [
              "appropriate",
              "250394"
            ],
            [
              "original",
              "167511"
            ],
          ]
        }
      ]
    ]
  }
}
{
  "total": 4,
  "items": {
    "xcloze": 2,
    "xchunk": 2
  },
  "data": {
    "xcloze": [
      [
        {
          "word": "tired",
          "sentiment": 0,
          "cands": [
            [
              "weak", //可替换的词
              0.0283, //weak 在 I am too tired/weak to move on. 的关联
              0.2589 //weak 与 tired 词性的关联距离
            ],
            [
              "hungry",
              0.0134,
              0.4132
            ]
          ]
        }
      ],
      [
        {
          "word": "box",
          "sentiment": 0,
          "cands": [
            [
              "clock",
              0.0438,
              0.0791
            ],
            [
              "surroundings",
              0.0142,
              0.0502
            ],
            [
              "noise",
              0.0135,
              0.0323
            ],[]
          ]
        }
      ]
    ],
    "xchunk": [
      [],
      [
        {
          "ibeg": 1,
          "iend": 4,
          "tag": "_jj",
          "offset": 1,
          "pattern": "pay _jj attention to",
          "cands": [
            [
              "close",
              "195392"
            ],
            [
              "particular",
              "159440"
            ],[]
            
          ]
        },
        {
          "ibeg": 4,
          "iend": 6,
          "tag": "_jj",
          "offset": 1,
          "pattern": "the _jj box",
          "cands": [
            [
              "appropriate",
              "250394"
            ],
            [
              "original",
              "167511"
            ],
          ]
        }
      ]
    ]
  }
}
名称类型必填说明
totalnumber提示总数
itemsobject分类总数
dataobject提示总数
  • data 下有 xcloze ,xchunk,xconfusion 表示xchunk语段层的建议提示,xcloze 近义词
  • xchunk 下[ xchunkType[], xchunkType[]] 每个句子对应的 xchunkType[]
  • xcloze 下[ xclozeType[], xclozeType[]] 每个句子对应的 xclozeType[]
  • xconfusion 下[ confusionType[], confusionType[]] 每个句子对应的 confusionType[]

xcloze 提示建议 类型

ts
 
interface xclozeType {
    "word": string //可选替换词
    "sentiment": -1|0|1 //词汇情感色彩 -1 贬义 0 中性 1 褒义
    "cands": any[][] //建议选项 key 0 未可选的值;key 1值 这个词汇在句子;key 2值 与替换词的词汇距离
}
 
interface xclozeType {
    "word": string //可选替换词
    "sentiment": -1|0|1 //词汇情感色彩 -1 贬义 0 中性 1 褒义
    "cands": any[][] //建议选项 key 0 未可选的值;key 1值 这个词汇在句子;key 2值 与替换词的词汇距离
}

xchunk 提示建议 类型

ts
 
interface xchunkType {
    "ibeg"?: number,
    "iend"?: number,
    "tag": string, //替换部分
    "offset": number, //偏移
    "pattern": string, //chunk 部分
    "cands": string[][] //建议选项:取二维中 0的值
}
 
interface xchunkType {
    "ibeg"?: number,
    "iend"?: number,
    "tag": string, //替换部分
    "offset": number, //偏移
    "pattern": string, //chunk 部分
    "cands": string[][] //建议选项:取二维中 0的值
}

六、错误、警告、提示三合一接口

  • 接口 POST https://url_cn/wpsv2?timeout=6

6.1 提交数据

  • timeout 超时时间 默认6s
json
{
  "snts": [
    "She has ready.",
    "Traffics is a big boxe."
    ] 
}
{
  "snts": [
    "She has ready.",
    "Traffics is a big boxe."
    ] 
}
名称类型必填说明
sntsstring[]分句后的句子

6.2 返回数据

json
{
    "snts": [
        "She has ready.",
        "Traffics is a big boxe."
    ],
    "err": [
        "xsntedits"
    ],
    "warn": [
        "xsntwarn",
        "xsntflue"
    ],
    "tip": [
        "xcloze",
        "xchunk",
        "xconfusion"
    ],
    "default": [
        "xsnttoks"
    ],
    "items": {
        "xsnttoks": 10,
        "xsntedits": 3,
        "xsntwarn": 2,
        "xsntflue": 2,
        "xcloze": 1,
        "xchunk": 0,
        "xconfusion": 1
    },
    "xsnttoks": [
        [
            {
                "i": 0,
                "offset": 0,
                "textws": "She "
            },
            {
                "i": 1,
                "offset": 4,
                "textws": "has "
            },
            {
                "i": 2,
                "offset": 8,
                "textws": "ready"
            },
            {
                "i": 3,
                "offset": 13,
                "textws": "."
            }
        ],
        [
            {
                "i": 0,
                "offset": 0,
                "textws": "Traffics "
            },
            {
                "i": 1,
                "offset": 9,
                "textws": "is "
            },
            {
                "i": 2,
                "offset": 12,
                "textws": "a "
            },
            {
                "i": 3,
                "offset": 14,
                "textws": "big "
            },
            {
                "i": 4,
                "offset": 18,
                "textws": "boxe"
            },
            {
                "i": 5,
                "offset": 22,
                "textws": "."
            }
        ]
    ],
    "xsntedits": [
        [
            {
                "offset": 4,
                "itok": 1,
                "iend": 2,
                "orig": "has",
                "corr": "is",
                "type": "R",
                "cate": "VERB",
                "of": "动词误用",
                "shortmsg": "建议<b>has</b>修改为<b>is</b>"
            }
        ],
        [
            {
                "offset": 18,
                "itok": 4,
                "iend": 5,
                "orig": "boxe",
                "corr": "box",
                "type": "R",
                "cate": "SPELL",
                "by": "rule",
                "of": "拼写错误",
                "shortmsg": "请检查<b>boxe</b>拼写",
                "cands": [
                    "box",
                    "bone",
                    "bore",
                    "boxer",
                    "boxes",
                    "boxed",
                    "Bose",
                    "boxy",
                    "bode",
                    "bole",
                    "BOE",
                    "BOX",
                    "boxen"
                ]
            },
            {
                "offset": 0,
                "itok": 0,
                "iend": 1,
                "orig": "Traffics",
                "corr": "Traffic",
                "type": "R",
                "cate": "NOUN:NUM",
                "of": "名词单复数错误",
                "shortmsg": "建议<b>Traffics</b>修改为<b>Traffic</b>"
            }
        ]
    ],
    "xsntwarn": [
        [],
        [
            {
                "type": "word",
                "pos": "NOUN",
                "ibeg": 0,
                "offset": 0,
                "wordlist": "Traffics",
                "shortmsg": "<b>Traffics</b> 一般不用复数形式",
                "by": "noun_noplual"
            },
            {
                "type": "NP",
                "ibeg": 2,
                "iend": 5,
                "offset": 12,
                "wordlist": "a big boxe",
                "cnt": 0,
                "shortmsg": "<b>a big boxe</b> 在本族语中很少使用"
            }
        ]
    ],
    "xsntflue": [
        [
            {
                "type": "sent",
                "snt": "She has ready.",
                "flue": 0.056,
                "by": "xsntflue"
            }
        ],
        [
            {
                "type": "sent",
                "snt": "Traffics is a big boxe.",
                "flue": 0.0884,
                "by": "xsntflue"
            }
        ]
    ],
    "xcloze": [
        [],
        [
            {
                "word": "big",
                "sentiment": 1,
                "cands": [
                    [
                        "compact",
                        0.0128,
                        0.1284
                    ],
                    [
                        "simple",
                        0.007,
                        0.2231
                    ],
                    [
                        "typical",
                        0.0065,
                        0.27
                    ]
                ]
            }
        ]
    ],
    "xchunk": [
        [],
        []
    ],
    "xconfusion": [
        [],
        [
            {
                "word": "Traffics",
                "lemma": "traffic",
                "pos": "NOUN",
                "ibeg": 0,
                "offset": 0,
                "of": "易混词汇",
                "cands": [
                    "communication",
                    "traffic",
                    "transportation"
                ]
            }
        ]
    ],
    "total": {
        "err": 3,
        "warn": 4,
        "tip": 2
    },
    "time": {
        "xsnttoks": 0.0021,
        "xsntedits": 0.0017,
        "xsntwarn": 0.0046,
        "xsntflue": 0.0415,
        "xcloze": 0.0431,
        "xchunk": 0.0321,
        "xconfusion": 0.0028,
        "total": 0.05
    }
}
{
    "snts": [
        "She has ready.",
        "Traffics is a big boxe."
    ],
    "err": [
        "xsntedits"
    ],
    "warn": [
        "xsntwarn",
        "xsntflue"
    ],
    "tip": [
        "xcloze",
        "xchunk",
        "xconfusion"
    ],
    "default": [
        "xsnttoks"
    ],
    "items": {
        "xsnttoks": 10,
        "xsntedits": 3,
        "xsntwarn": 2,
        "xsntflue": 2,
        "xcloze": 1,
        "xchunk": 0,
        "xconfusion": 1
    },
    "xsnttoks": [
        [
            {
                "i": 0,
                "offset": 0,
                "textws": "She "
            },
            {
                "i": 1,
                "offset": 4,
                "textws": "has "
            },
            {
                "i": 2,
                "offset": 8,
                "textws": "ready"
            },
            {
                "i": 3,
                "offset": 13,
                "textws": "."
            }
        ],
        [
            {
                "i": 0,
                "offset": 0,
                "textws": "Traffics "
            },
            {
                "i": 1,
                "offset": 9,
                "textws": "is "
            },
            {
                "i": 2,
                "offset": 12,
                "textws": "a "
            },
            {
                "i": 3,
                "offset": 14,
                "textws": "big "
            },
            {
                "i": 4,
                "offset": 18,
                "textws": "boxe"
            },
            {
                "i": 5,
                "offset": 22,
                "textws": "."
            }
        ]
    ],
    "xsntedits": [
        [
            {
                "offset": 4,
                "itok": 1,
                "iend": 2,
                "orig": "has",
                "corr": "is",
                "type": "R",
                "cate": "VERB",
                "of": "动词误用",
                "shortmsg": "建议<b>has</b>修改为<b>is</b>"
            }
        ],
        [
            {
                "offset": 18,
                "itok": 4,
                "iend": 5,
                "orig": "boxe",
                "corr": "box",
                "type": "R",
                "cate": "SPELL",
                "by": "rule",
                "of": "拼写错误",
                "shortmsg": "请检查<b>boxe</b>拼写",
                "cands": [
                    "box",
                    "bone",
                    "bore",
                    "boxer",
                    "boxes",
                    "boxed",
                    "Bose",
                    "boxy",
                    "bode",
                    "bole",
                    "BOE",
                    "BOX",
                    "boxen"
                ]
            },
            {
                "offset": 0,
                "itok": 0,
                "iend": 1,
                "orig": "Traffics",
                "corr": "Traffic",
                "type": "R",
                "cate": "NOUN:NUM",
                "of": "名词单复数错误",
                "shortmsg": "建议<b>Traffics</b>修改为<b>Traffic</b>"
            }
        ]
    ],
    "xsntwarn": [
        [],
        [
            {
                "type": "word",
                "pos": "NOUN",
                "ibeg": 0,
                "offset": 0,
                "wordlist": "Traffics",
                "shortmsg": "<b>Traffics</b> 一般不用复数形式",
                "by": "noun_noplual"
            },
            {
                "type": "NP",
                "ibeg": 2,
                "iend": 5,
                "offset": 12,
                "wordlist": "a big boxe",
                "cnt": 0,
                "shortmsg": "<b>a big boxe</b> 在本族语中很少使用"
            }
        ]
    ],
    "xsntflue": [
        [
            {
                "type": "sent",
                "snt": "She has ready.",
                "flue": 0.056,
                "by": "xsntflue"
            }
        ],
        [
            {
                "type": "sent",
                "snt": "Traffics is a big boxe.",
                "flue": 0.0884,
                "by": "xsntflue"
            }
        ]
    ],
    "xcloze": [
        [],
        [
            {
                "word": "big",
                "sentiment": 1,
                "cands": [
                    [
                        "compact",
                        0.0128,
                        0.1284
                    ],
                    [
                        "simple",
                        0.007,
                        0.2231
                    ],
                    [
                        "typical",
                        0.0065,
                        0.27
                    ]
                ]
            }
        ]
    ],
    "xchunk": [
        [],
        []
    ],
    "xconfusion": [
        [],
        [
            {
                "word": "Traffics",
                "lemma": "traffic",
                "pos": "NOUN",
                "ibeg": 0,
                "offset": 0,
                "of": "易混词汇",
                "cands": [
                    "communication",
                    "traffic",
                    "transportation"
                ]
            }
        ]
    ],
    "total": {
        "err": 3,
        "warn": 4,
        "tip": 2
    },
    "time": {
        "xsnttoks": 0.0021,
        "xsntedits": 0.0017,
        "xsntwarn": 0.0046,
        "xsntflue": 0.0415,
        "xcloze": 0.0431,
        "xchunk": 0.0321,
        "xconfusion": 0.0028,
        "total": 0.05
    }
}

6.3 返回数据说明

字段类型说明
errstring[]错误字段 可能包含 xsntedits
warnstring[]警告字段 可能包含 xsntwarn xsntflue
tipstring[]提示字段 可能包含 xcloze xchunk xconfusion
totaltotalType合计数据里面包含了 err warn tip
itemsitemsType分类数据合计
xsnttokstoksType[][]带空格分词的数据,第一层句子下标,第二层单词下标
xsnteditseditType[][]第一层句子下标,第二层单词下标
xsntwarnxsntwarnType[][]第一层句子下标,第二层单词下标
xconfusionconfusionType[][]第一层句子下标,第二层单词下标
xsntflueflueType[][]第一层句子下标,第二层单词下标
xclozexclozeType[][]第一层句子下标,第二层单词下标
xchunkxchunkType[][]第一层句子下标,第二层单词下标
timetimeType时间消耗

结构体字段说明

totalType 字段说明

ts
interface totalType { 
    "err": number
    "warn": number
    "tip":number
}
interface totalType { 
    "err": number
    "warn": number
    "tip":number
}

itemsType 字段说明

ts
interface itemsType {
    "xsnttoks": number
    "xsntedits": number
    "xsntwarn": number
    "xsntflue": number
    "xcloze": number
    "xchunk": number
    "xconfusion":number
}
interface itemsType {
    "xsnttoks": number
    "xsntedits": number
    "xsntwarn": number
    "xsntflue": number
    "xcloze": number
    "xchunk": number
    "xconfusion":number
}

toksType 字段说明

ts
interface toksType { 
    "i": number //在句子中的分词位置
    "offset": number //在句子中的字符串位置
    "textws": string //带空格的分词
}
interface toksType { 
    "i": number //在句子中的分词位置
    "offset": number //在句子中的字符串位置
    "textws": string //带空格的分词
}

editType 字段说明

ts
export interface editType{  
    "offset": number
    "itok": number //toks中的开始的位置
    "iend": number //toks中的结束前的位置
    "orig": string
    "corr":string
    "type": "R"|"M"|"U" //R替换 M新增 U删除
    "cate":string
    "of"?:string //类别汉化
    "shortmsg":string //建议
    isModify?:boolean  //是否修改 修改接替换 这个属性需要自己添加
    cands?:string[]  //可替换的选项 选项多的时候放这个字段
    context?:any[] //替换词汇 下标0|1 都是 number 2 string
}
export interface editType{  
    "offset": number
    "itok": number //toks中的开始的位置
    "iend": number //toks中的结束前的位置
    "orig": string
    "corr":string
    "type": "R"|"M"|"U" //R替换 M新增 U删除
    "cate":string
    "of"?:string //类别汉化
    "shortmsg":string //建议
    isModify?:boolean  //是否修改 修改接替换 这个属性需要自己添加
    cands?:string[]  //可替换的选项 选项多的时候放这个字段
    context?:any[] //替换词汇 下标0|1 都是 number 2 string
}

xclozeType 提示建议 类型

ts
interface xclozeType {
    "word": string //可选替换词
    "sentiment": -1|0|1 //词汇情感色彩 -1 贬义 0 中性 1 褒义
    "cands": any[][] //建议选项 key 0 未可选的值;key 1值 这个词汇在句子;key 2值 与替换词的词汇距离
}
interface xclozeType {
    "word": string //可选替换词
    "sentiment": -1|0|1 //词汇情感色彩 -1 贬义 0 中性 1 褒义
    "cands": any[][] //建议选项 key 0 未可选的值;key 1值 这个词汇在句子;key 2值 与替换词的词汇距离
}

xchunkType 提示建议 类型

ts
 
interface xchunkType {
    "ibeg"?: number,
    "iend"?: number,
    "tag": string, //替换部分
    "offset": number, //偏移
    "pattern": string, //chunk 部分
    "cands": string[][] //建议选项:取二维中 0的值
}
 
interface xchunkType {
    "ibeg"?: number,
    "iend"?: number,
    "tag": string, //替换部分
    "offset": number, //偏移
    "pattern": string, //chunk 部分
    "cands": string[][] //建议选项:取二维中 0的值
}

xsntwarnType 字段说明

ts
interface xsntwarnType {
   "type": string //类型
    "offset"?:  number
    "wordlist": string //当前的匹配词或词组
    "shortmsg":string // 提示信息
    "by": string //引擎模块名称
}
interface xsntwarnType {
   "type": string //类型
    "offset"?:  number
    "wordlist": string //当前的匹配词或词组
    "shortmsg":string // 提示信息
    "by": string //引擎模块名称
}

flueType 字段说明

ts
interface flueType{
    "type": string //类型
    "snt": string
    "flue": number //流畅
    "by":string //引擎模块名称
}
interface flueType{
    "type": string //类型
    "snt": string
    "flue": number //流畅
    "by":string //引擎模块名称
}

confusionType 字段说明

ts
interface confusionType{
    "word": string //替换词
    "lemma": string //替换词词汇
    "pos":string, //词性类别
    "ibeg": number //句中词汇的开始位置
    "offset": number //句中字符串的开始位置
    "of": string //类别汉化
    "cands": string[] //可替换词汇        
}
interface confusionType{
    "word": string //替换词
    "lemma": string //替换词词汇
    "pos":string, //词性类别
    "ibeg": number //句中词汇的开始位置
    "offset": number //句中字符串的开始位置
    "of": string //类别汉化
    "cands": string[] //可替换词汇        
}

timeType 字段说明

ts
interface timeType {
    "xsnttoks"?: number
    "xsntedits"?: number
    "xsntwarn"?: number
    "xsntflue"?: number
    "xcloze"?: number
    "xchunk"?: number
    "xconfusion"?:number
    "total":number //总耗时
}
interface timeType {
    "xsnttoks"?: number
    "xsntedits"?: number
    "xsntwarn"?: number
    "xsntflue"?: number
    "xcloze"?: number
    "xchunk"?: number
    "xconfusion"?:number
    "total":number //总耗时
}