词库管理接口

概念

entities接口用于对普通词库进行增删改查操作

URLs

基本的url:

url 说明 备注
GET /entities 获取所有词库 暂无
GET /entities/{eid} 获取单个词库 暂无
POST /entities 添加词库 暂无
POST /entities/{eid}/entries 向词库添加词 暂无
PUT /entities 添加或者修改词库 暂无
PUT /entities/{eid} 修改词库 暂无
PUT /entities/{eid}/entities 修改词库中的词 暂无
DELETE /entities/{eid} 删除词库 暂无
DELETE /entities/{eid}/entries 删除词库中的词 暂无

GET /entities

获取所有词库

GET http://api.yige.ai/v1/entities
Headers:
Authorization:您的开发者令牌

CURL示例:

curl -k -H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
"http://api.yige.ai/v1/entities"

响应示例:

{
    "entities": [
        {
            "id": "5A7ACD8F-044F-B8F4-2181-43A6B19B87CB",
            "name": "跑鞋类型"
        },
        {
            "id": "43F922C5-3E1A-0F97-C778-7E5F5291CB16",
            "name": "脚型"
        }
    ],
    "status": {
        "code": 200,
        "error_msg": "success"
    }
}

GET /entities/{eid}

获取单个词库

参数说明:

{eid} 您的词库ID

GET http://api.yige.ai/v1/entities/E2E9C243-5F84-DD7A-81D8-649C2CF68C59
Headers:
Authorization:您的开发者令牌

CURL示例:

curl -k -H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
"http://api.yige.ai/v1/entities/5A7ACD8F-044F-B8F4-2181-43A6B19B87CB"

响应示例:

{
    "entities": [
        {
            "id": "5A7ACD8F-044F-B8F4-2181-43A6B19B87CB",
            "agent_id": "0CCE796C-EFA7-3F50-64FB-F26290CE542E",
            "name": "跑鞋类型",
            "entries": [
                {
                    "value": "缓震型",
                    "synonyms": [
                        "缓震型",
                        "缓震",
                        "缓冲型",
                        "缓冲"
                    ]
                },
                {
                    "value": "支撑型",
                    "synonyms": [
                        "支撑型",
                        "支撑"
                    ]
                },
                {
                    "value": "越野型",
                    "synonyms": [
                        "越野型",
                        "越野"
                    ]
                },
                {
                    "value": "竞速型",
                    "synonyms": [
                        "竞速型",
                        "竞速"
                    ]
                },
                {
                    "value": "赤足型",
                    "synonyms": [
                        "赤足型",
                        "赤足"
                    ]
                }
            ],
            "user_defined": null,
            "type": 1,
            "automated_expansion": 0,
            "state": 1,
            "created_at": "1476703769",
            "updated_at": "1476703863",
            "alias_name": "paoxieleixing",
            "refcount": 0
        }
    ],
    "status": {
        "code": 200,
        "error_msg": "success"
    }
}

POST /entities

添加词库

POST http://api.yige.ai/v1/entities/
Headers:
Authorization: 您的开发者令牌
Content-Type: application/json; charset=utf-8
POST body:
{
    "name":"脚型",
    "type":"1",
    "automated_expansion":"0",
    "entries": [
        {
            "value": "足内翻",
            "synonyms": [
                "足内翻",
                "内翻",
                "内旋不足",
                "不足内旋",
                "高足弓",
                "足弓高"
            ]
        },
        {
            "value": "正常内旋",
            "synonyms": [
                "正常内旋",
                "内旋正常",
                "正常足弓",
                "足弓正常"
            ]
        },
        {
            "value": "足外翻",
            "synonyms": [
                "足外翻",
                "外翻",
                "过度内旋",
                "内旋过度",
                "低足弓",
                "足弓低",
                "平足"
            ]
        }
    ]  
}

CURL示例:

curl -k \
-H "Content-Type: application/json; charset=utf-8" \
-H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
--data '{
    "name":"脚型",
    "type":"1",
    "automated_expansion":"0",
    "entries": [
        {
            "value": "足内翻",
            "synonyms": [
                "足内翻",
                "内翻",
                "内旋不足",
                "不足内旋",
                "高足弓",
                "足弓高"
            ]
        },
        {
            "value": "正常内旋",
            "synonyms": [
                "正常内旋",
                "内旋正常",
                "正常足弓",
                "足弓正常"
            ]
        },
        {
            "value": "足外翻",
            "synonyms": [
                "足外翻",
                "外翻",
                "过度内旋",
                "内旋过度",
                "低足弓",
                "足弓低",
                "平足"
            ]
        }
    ]  
}' "http://api.yige.ai/v1/entities"

响应示例:

{
    "status": {
        "code": 200,
        "error_msg": "success"
    },
    "id": {
        "id": "43F922C5-3E1A-0F97-C778-7E5F5291CB16"
    }
}

POST /entities/{eid}/entries

向词库添加词

参数说明:

{eid} 您的词库ID

POST http://api.yige.ai/v1/entities/7155114B-9886-CAA3-DFD4-C43D9691CB23/entries
Headers:
Authorization: Bearer 您的开发者令牌
Content-Type: application/json; charset=utf-8
POST body:
[
      {
          "value": "赤足型",
          "synonyms": [
              "赤足型",
              "赤足"
          ]
      },
      {
          "value": "竞速型",
          "synonyms": [
              "竞速型",
              "竞速"
          ]
      }
]

cUrl示例:

curl -i -X POST \
-H "Content-Type: application/json; charset=utf-8" \
-H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
-d '[
        {
            "value": "赤足型",
            "synonyms": [
                "赤足型",
                "赤足"
            ]
        },
        {
            "value": "竞速型",
            "synonyms": [
                "竞速型",
                "竞速"
            ]
        }
]' "http://api.yige.ai/v1/entities/5A7ACD8F-044F-B8F4-2181-43A6B19B87CB/entries"

响应示例:

{
  "status": {
    "code": 200,
    "error_msg": "success"
  },
  "id": "7155114B-9886-CAA3-DFD4-C43D9691CB23"
}

PUT /entities

添加或者修改词库

cUrl示例:

curl -k -X PUT \
-H "Content-Type: application/json; charset=utf-8" \
-H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
-d '[
    {
        "name": "鞋尺码",
        "entries": [
            {
                "value": "{yige.quantity_number:num}码",
                "synonyms": ""
            },
            {
                "value": "{yige.quantity_number:num}",
                "synonyms": ""
            }
        ]
    },
    {
        "name": "鞋系列",
        "entries": [
            {
                "value": "Nimbus",
                "synonyms": [
                    "Nimbus",
                    "NIMBUS",
                    "GELNIMBUS",
                    "nimbus",
                    "Nimbus18",
                    "Nimbus-18",
                    "Nimbus 18"
                ]
            }
        ]
    }
]' "http://api.yige.ai/v1/entities"

响应示例:

{
    "status": {
        "code": 200,
        "error_msg": "success"
    }
}

PUT /entities/{eid}

修改词库

参数说明:

{eid} 您的词库ID

cUrl示例:

curl -k -X PUT \
-H "Content-Type: application/json; charset=utf-8" \
-H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
-d '{
    "name":"鞋系列",
    "type":"1",
    "automated_expansion":"0",
    "entries":[
        {
            "value": "Nimbus",
            "synonyms": [
                "Nimbus",
                "NIMBUS",
                "GELNIMBUS",
                "nimbus",
                "Nimbus18",
                "Nimbus-18",
                "Nimbus 18"
            ]
        },
        {
            "value": "Cumulus",
            "synonyms": [
                "Cumulus",
                "CUMULUS",
                "cumulus"
            ]
        },
        {
            "value": "Kayano",
            "synonyms": [
                "Kayano",
                "KAYANO",
                "GELKAYANO",
                "kayano"
            ]
        }
    ]
}' "http://api.yige.ai/v1/entities/4754E551-8042-3702-4CFB-2343544B5175"

响应示例:

{
  "status": {
    "code": 200,
    "error_msg": "success"
  }
}

PUT /entities/{eid}/entries

修改词库中的词

参数说明:

{eid} 您的词库ID

curl -i -X PUT \
-H "Accept:application/json" \
-H "Content-Type:application/json" \
-H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
-d '[
        {
            "value": "Kayano",
            "synonyms": [
                "Kayano",
                "KAYANO",
                "GELKAYANO",
                "kayano"
            ]
        }
]' "http://api.yige.ai/v1/entities/4754E551-8042-3702-4CFB-2343544B5175/entries"

响应示例:

{
  "status": {
    "code": 200,
    "error_msg": "词库条目更新成功"
  }
}

DELETE /entities/{eid}

删除词库

参数说明:

{eid} 您的词库ID

DELETE http://api.yige.ai/v1/entities/4754E551-8042-3702-4CFB-2343544B5175
Headers:
Authorization:您的开发者令牌

curl示例:

curl -k -X DELETE  \
-H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
"http://api.yige.ai/v1/entities/4754E551-8042-3702-4CFB-2343544B5175"

响应示例:

{
    "status": {
        "code": 200,
        "error_msg": "删除成功"
    }
}

DELETE /entities/{eid}/entries

删除词库中的词

参数说明:

{eid} 您的词库ID

cUrl示例:

curl -i -X DELETE \
  -H "Accept:application/json" \
  -H "Content-Type:application/json" \
  -H "Authorization:8F97ED3ACBB7DE3228DC0002959A6F82" \
  -d \
'[
  "Cumulus",
  "Kayano"
]' 'http://api.yige.ai/v1/entities/4754E551-8042-3702-4CFB-2343544B5175/entries'

响应示例:

{
    "status": {
        "code": 200,
        "error_msg": "词库条目删除成功"
    }
}

词库对象

名称 类型 描述
id String 自增id
agent_id String 应用id
name String 词库名称
entries Array of objects 参考 "词库对象中的词库数组"
type int 类型
automated_expansion int 自动扩展
state int 状态
created_at int 创建时间
updated_at int 更新时间
alias_name String 别名
{
    "id": "A9F9017F-A564-0E1F-C6E5-910BF44FCBF0",
    "name": "跑鞋类型",
    "entries": [
        {
            "value": "缓震型",
            "synonyms": [
                "缓震型",
                "缓震",
                "缓冲型",
                "缓冲"
            ]
        },
        {
            "value": "支撑型",
            "synonyms": [
                "支撑型",
                "支撑"
            ]
        },
        {
            "value": "越野型",
            "synonyms": [
                "越野型",
                "越野"
            ]
        },
        {
            "value": "竞速型",
            "synonyms": [
                "竞速型",
                "竞速"
            ]
        },
        {
            "value": "赤足型",
            "synonyms": [
                "赤足型",
                "赤足"
            ]
        }
    ],
    "user_defined": null,
    "type": 1,
    "automated_expansion": 0,
    "state": 1,
    "created_at": "1476703769",
    "updated_at": "1476703863",
    "alias_name": "paoxieleixing",
    "refcount": 0
}

词库对象中的词库数组

名称 类型 描述
value String 词的名称
synonyms String OR Array 词库的同义词

词库示例:

 [
      {
          "value": "缓震型",
          "synonyms": [
              "缓震型",
              "缓震",
              "缓冲型",
              "缓冲"
          ]
      },
      {
          "value": "支撑型",
          "synonyms": [
              "支撑型",
              "支撑"
          ]
      }
]

results matching ""

    No results matching ""