功能描述
提交一个分词任务。
授权说明
子账号使用异步处理接口时,需要授予 cam:passrole 权限,异步处理接口会通过 CAM 的“角色”进行 COS 的资源读写操作,PassRole 权限用于传递角色。
服务开通
使用该功能需提前开通数据万象,并绑定存储桶。详情请参见 绑定存储桶。
使用该功能需提前通过控制台或接口开通 AI 内容识别服务 。详情请参见 开通 AI 内容识别服务。
使用限制
费用说明
请求
请求示例
POST /jobs HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml<body>
请求头
请求体
该请求操作的实现需要有如下请求体。
<Request><Tag>WordsGeneralize</Tag><Input><Object>text.txt</Object></Input><Operation><WordsGeneralize><NerMethod>DL</NerMethod><SegMethod>MIX</SegMethod></WordsGeneralize><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation><CallBack>http://callback.demo.com</CallBack><CallBackFormat>JSON<CallBackFormat></Request>
具体的数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Request | 无 | 保存请求的容器 | Container | 是 |
Container 类型 Request 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Tag | Request | 创建任务的 Tag:WordsGeneralize | String | 是 |
Input | Request | 待操作的对象信息 | Container | 是 |
Operation | Request | 操作规则 | Container | 是 |
CallBackFormat | Request | 任务回调格式,JSON 或 XML,默认 XML,优先级高于队列的回调格式 | String | 否 |
CallBackType | Request | 任务回调类型,Url 或 TDMQ,默认 Url,优先级高于队列的回调类型 | String | 否 |
CallBack | Request | 任务回调地址,优先级高于队列的回调地址。设置为 no 时,表示队列的回调地址不产生回调 | String | 否 |
CallBackMqConfig | Request | 任务回调 TDMQ 配置,当 CallBackType 为 TDMQ 时必填。详情见 CallBackMqConfig | Container | 否 |
Container 类型 Input 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
Object | Request.Input | 文件路径 | String | 是 |
Container 类型
Operation
的具体数据描述如下:节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
WordsGeneralize | Request.Operation | 指定分词参数 | Container | 是 |
UserData | Request.Operation | 透传用户信息,可打印的 ASCII 码,长度不超过1024 | String | 否 |
JobLevel | Request.Operation | 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0 | String | 否 |
Container 类型 WordsGeneralize 的具体数据描述如下:
节点名称(关键字) | 父节点 | 描述 | 类型 | 是否必选 |
NerMethod | Request.Operation.WordsGeneralize | ner 方式,支持 NerBasic 和 DL,默认值 DL | String | 否 |
SegMethod | Request.Operation.WordsGeneralize | 分词粒度,支持 SegBasic 和 MIX,默认值 MIX | String | 否 |
响应
响应头
响应体
该响应体返回为 application/xml 数据,包含完整节点数据的内容展示如下:
<Response><JobsDetail><Code>Success</Code><Message/><JobId>ac7c990a00bf211ed946af9e0691f2b7a</JobId><State>Submitted</State><CreationTime>2022-06-27T14:44:10+0800</CreationTime><StartTime>-</StartTime><EndTime>-</EndTime><QueueId>pcd463e1467964d39ad2d3f66aacd8199</QueueId><Tag>WordsGeneralize</Tag><Input><Object>text.txt</Object></Input><Operation><WordsGeneralize><NerMethod>DL</NerMethod><SegMethod>MIX</SegMethod></WordsGeneralize><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation></JobsDetail></Response>
具体的数据内容如下:
节点名称(关键字) | 父节点 | 描述 | 类型 |
Response | 无 | 保存结果的容器 | Container |
Container 节点 Response 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
JobsDetail | Response | 任务的详细信息 | Container 数组 |
Container 节点
JobsDetail
的内容:节点名称(关键字) | 父节点 | 描述 | 类型 |
Code | Response.JobsDetail | 错误码,只有 State 为 Failed 时有意义 | String |
Message | Response.JobsDetail | 错误描述,只有 State 为 Failed 时有意义 | String |
JobId | Response.JobsDetail | 创建任务的 ID | String |
Tag | Response.JobsDetail | 创建任务的 Tag:WordsGeneralize | String |
State | Response.JobsDetail | 任务状态 Submitted:已提交,待执行 Running:执行中 Success:执行成功 Failed:执行失败 Pause:任务暂停,当暂停队列时,待执行的任务会变为暂停状态 Cancel:任务被取消执行 | String |
CreationTime | Response.JobsDetail | 任务的创建时间 | String |
StartTime | Response.JobsDetail | 任务的开始时间 | String |
EndTime | Response.JobsDetail | 任务的结束时间 | String |
QueueId | Response.JobsDetail | String | |
Input | Response.JobsDetail | 同请求中的 Request.Input 节点 | Container |
Operation | Response.JobsDetail | 该任务的规则 | Container |
Container 节点 Operation 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
WordsGeneralize | Response.JobsDetail.Operation | 同请求中的 Request.Operation.WordsGeneralize | Container |
UserData | Response.JobsDetail.Operation | 透传用户信息 | String |
JobLevel | Response.JobsDetail.Operation | 任务优先级 | String |
WordsGeneralizeResult | Response.JobsDetail.Operation | 分词结果,任务执行成功时返回 | Container |
Container 节点 WordsGeneralizeResult 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
WordsGeneralizeLable | Response.JobsDetail.Operation.WordsGeneralizeResult | 智能分类结果 | Container 数组 |
WordsGeneralizeToken | Response.JobsDetail.Operation.WordsGeneralizeResult | 分词详细结果 | Container 数组 |
Container 节点 WordsGeneralizeLable 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
Category | Response.JobsDetail.Operation.WordsGeneralizeResult.WordsGeneralizeLable | 类别 | String |
Word | Response.JobsDetail.Operation.WordsGeneralizeResult.WordsGeneralizeLable | 词汇 | String |
Container 节点 WordsGeneralizeToken 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
Word | Response.JobsDetail.Operation.WordsGeneralizeResult.WordsGeneralizeToken | 词汇 | String |
Offset | Response.JobsDetail.Operation.WordsGeneralizeResult.WordsGeneralizeToken | 偏移量 | String |
Length | Response.JobsDetail.Operation.WordsGeneralizeResult.WordsGeneralizeToken | 词汇长度 | String |
Pos | Response.JobsDetail.Operation.WordsGeneralizeResult.WordsGeneralizeToken | 词性 | String |
词性详见下标:
英文缩写 | 含义 |
A | 形容词 |
AD | 副形词 |
AN | 名形词 |
B | 区别词 |
C | 连词 |
D | 副词 |
E | 叹词 |
F | 方位词 |
G | 语素词 |
H | 前接成分 |
I | 成语 |
J | 简称略语 |
K | 后接成分 |
L | 习用语 |
M | 数词 |
N | 名词 |
NR | 人名 |
NRF | 姓 |
NRG | 名 |
NS | 地名 |
NT | 机构团体 |
NZ | 其他专名 |
NX | 非汉字串 |
O | 拟声词 |
P | 介词 |
Q | 量词 |
R | 代词 |
S | 处所词 |
T | 时间词 |
U | 助词 |
V | 动词 |
VD | 副动词 |
VN | 名动词 |
W | 标点符号 |
X | 非语素字 |
Y | 语气词 |
Z | 状态词 |
AG | 形语素 |
BG | 区别语素 |
DG | 副语素 |
MG | 数词性语素 |
NG | 名语素 |
QG | 量语素 |
RG | 代语素 |
TG | 动语素 |
VG | 量语素 |
YG | 语气词语素 |
ZG | 状态词语素 |
UNK | 未知词性 |
错误码
实际案例
请求
POST /jobs HTTP/1.1Authorization: q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0a1ICvR****&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=28e9a4986df11bed0255e97ff90500557e0ea057Host: test-1234567890.ci.ap-beijing.myqcloud.comContent-Length: 166Content-Type: application/xml<Request><Tag>WordsGeneralize</Tag><Input><Object>text.txt</Object></Input><Operation><WordsGeneralize><NerMethod>DL</NerMethod><SegMethod>MIX</SegMethod></WordsGeneralize><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation><CallBack>http://callback.demo.com</CallBack><CallBackFormat>JSON<CallBackFormat></Request>
响应
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 230Connection: keep-aliveDate: Mon, 28 Jun 2022 15:23:12 GMTServer: tencent-cix-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****<Response><JobsDetail><Code>Success</Code><Message/><JobId>ac7c990a00bf211ed946af9e0691f2b7a</JobId><State>Submitted</State><CreationTime>2022-06-27T14:44:10+0800</CreationTime><StartTime>-</StartTime><EndTime>-</EndTime><QueueId>pcd463e1467964d39ad2d3f66aacd8199</QueueId><Tag>WordsGeneralize</Tag><Input><Object>text.txt</Object></Input><Operation><WordsGeneralize><NerMethod>DL</NerMethod><SegMethod>MIX</SegMethod></WordsGeneralize><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation></JobsDetail></Response>