
# 实体识别接口
#### 场景描述
给第三方接入方调用,实现实体识别能力。
![](https://support.huaweicloud.com/api-ccfs-cec/public_sys-resources/notice_3.0-zh-cn.png)
如果需要使用Lodas的实体识别模型,调用实体识别接口之前,请先完成实体识别功能调测,具体操作请参见《OIAP 产品文档》的调测实体提取模型功能章节。
#### 接口方法
设置成"POST"。
#### URL
https://IP:PORT/oifde/rest/api/entityDetection
#### 请求说明
表1请求体参数 
| 参数名称      | 数据类型   | 参数位置 | 必选/可选 | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|:---|:---|
| tenantId  | String | body | True  | 租户ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| language  | String | body | True  | 语言。选项如下： - zh_CN：中文  - en_US：英文  - es_ES：西班牙语  - ar：阿拉伯语  - th_TH：泰语  - pt_BR：葡萄牙语 **说明**： 1. 基于Tuc的实体识别,支持如上选项语种。  2. 基于Lodas的实体识别,支持语言以Lodas实体识别模型为准。     |
| sentence  | String | body | True  | 输入语句。 实体识别的依据,最大长度4096字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| authToken | String | body | True  | 认证token。 请参见[C3 智能助手平台接口鉴权方式](https://support.huaweicloud.com/api-ccfs-cec/cec_07_0004.html)。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
   
#### 响应说明
| 参数名称            | 数据类型            | 参数位置 | 必选/可选 | 描述       |
|:---|:---|:---|:---|:---|
| count           | int             | body | True  | 识别出的实体个数 |
| entityMsgV2List | EntityMsgV2\[\] | body | True  | 实体对象列表   |
   
表2EntityMsgV2 
| Name       | Mandatory | Type                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|:---|:---|:---|:---|
| citation   | True      | String               | 实体的引用名称 例如,系统实体中地址的引用名称 @system.address                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| type       | True      | int                  | 实体类型 - -1：系统或环境实体,非用户实体    - 0：一般实体  - 1：组合实体  - 2：规则实体  - 3：通过Lodas识别的实体   |
| userEntity | True      | boolean              | 是否为用户实体                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| envEntity  | True      | boolean              | 是否为环境实体                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| beginIndex | True      | int                  | 识别到实体值,在输入语句中的开始序号                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| endIndex   | True      | int                  | 识别到实体值,在输入语句中的结束序号                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| values     | True      | Map\<String,String\> | 具体识别出的实体值对 实体种类：实体值 例如："@system.address": "湖南省长沙市岳麓区"。 具体操作请参考添加实体章节。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| formats    | True      | List\<String\>       | 识别到实体的引用格式的列表 例如：\["raw","province"\], "raw"为原始值,"province"为省份。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
   
#### 报文样例
- 请求样例
  ```
  { 
      "tenantId":"202104237142",
      "language":"zh_CN",
      "sentence":"长沙岳麓区岳麓大道旺龙路,下雨天积水严重,影响出行",
      "authToken":"E2mjXcv*******************XX1av"
  }
  ```
  
- 响应样例
  ```
  {
      "count": 4,
      "entityMsgV2List": [
          {
              "citation": "@system.any",  // 匹配任意用户输入
              "type": -1,
              "userEntity": false,
              "envEntity": false,
              "beginIndex": 0,
              "endIndex": 25,
              "values": {
                  "@system.any": "长沙岳麓区岳麓大道旺龙路,下雨天积水严重,影响出行",
                  "@system.any.raw": "长沙岳麓区岳麓大道旺龙路,下雨天积水严重,影响出行"
              },
              "formats": [
                  "raw"
              ]
          },
          {
              "citation": "@system.env.time", // 当前时间
              "type": -1,
              "userEntity": false,
              "envEntity": true,
              "beginIndex": -1,
              "endIndex": -1,
              "values": {
                  "@system.env.time.hour": "11",
                  "@system.env.time.minute": "09",
                  "@system.env.time": "11:09"
              },
              "formats": [
                  "hour",
                  "minute"
              ]
          },
          {
              "citation": "@system.env.date", // 当前日期
              "type": -1,
              "userEntity": false,
              "envEntity": true,
              "beginIndex": -1,
              "endIndex": -1,
              "values": {
                  "@system.env.date.yyyyMM": "202110",
                  "@system.env.date": "2021-10-19",
                  "@system.env.date.year": "2021",
                  "@system.env.date.month": "10",
                  "@system.env.date.day": "19"
              },
              "formats": [
                  "yyyyMM",
                  "year",
                  "month",
                  "day"
              ]
          },
          {
              "citation": "@system.address", // 地址检测
              "type": -1,
              "userEntity": false,
              "envEntity": false,
              "beginIndex": 0,
              "endIndex": 5,
              "values": {
                  "@system.address.raw": "长沙岳麓区",
                  "@system.address": "湖南省长沙市岳麓区",
                  "@system.address.province": "湖南省"
              },
              "formats": [
                  "raw",
                  "province"
              ]
          }
      ]
  }
  ```
  
 
