NLI(Natural Language Interface,自然语言接口),用于识别处理自然语言的接口。输入为一句话,返回包含【意图】,【参数】等结构化数据,是一种面向对话的人机交互接口。
使用人数:123人
机票查询NLI

  1. 接口介绍: 识别一句话描述中包含的机票查询数据。
  2. 接口地址: http://open-nli.luzhi.online/flight
  3. 请求方式: GET
  4. 返回格式: JSON
  5. 请求参数说明:
    名称 必须 类型 说明
    token String 接口调用授权签名
    query String 语言话术
  6. 请求示例:
    http://open-nli.luzhi.online/flight?token=***&query=明天北京到杭州的机票
  7. 返回参数:
    名称 类型 说明
    code int 响应码,成功为200。
    msg String 返回消息。成功返回Succeed。其余错误消息为对应错误码的提示。
    data Object 返回数据。数据类型为Json,遵循NLI协议规范
    data数据说明:
    intention string 意图标识 flight
    intentionData JObject 意图对应的参数(词槽)
  8. 正确返回示例:
    {
      "code": 200,
      "msg": "succeed",
      "data": {
        "intention": "flight",
        "intentionData": {
          "origin_time": "明天",
          "day_time": "2019-10-03",
          "depart_city": "北京",
          "arrive_city": "杭州"
        }
      }
    }
  9. 错误返回示例:
    {
      "code": 401,
      "message": "Sign is error",
      "data": null
    }
  10. 参考代码:

    
            //using System.IO;
            //using System.Text;
            //using System.Net;
            //using System.Net.Security;
            static void Main(string[] args)
            {
                String method = "GET";
                String url = "http://open-nli.luzhi.online/flight?token=***&query=明天北京到杭州的机票";
                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); 
                httpRequest.Method = method;
                try
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    Stream st = httpResponse.GetResponseStream();
                    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
                    Console.WriteLine(reader.ReadToEnd());
                    Console.WriteLine("\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
                                                 

    
        public static void main(String[] args) throws IOException
        { 
            String url = "http://open-nli.luzhi.online/flight?token=***&query=明天北京到杭州的机票";
        
            HttpClient httpClient = HttpClients.custom().build();
            HttpGet get = new HttpGet(url);
        
            HttpResponse response = httpClient.execute(get);
            HttpEntity resp_entity = response.getEntity();
            resp_entity.getContent();
        
            String resp_content = EntityUtils.toString(resp_entity,StandardCharsets.UTF_8);
        
            System.out.println(resp_content);
        } 
                                             

    
        import json, urllib
        from urllib import urlencode
    
        url = "http://open-nli.luzhi.online/flight?token=***&query=明天北京到杭州的机票"
        params = { 
            "token": "*************",           # 授权签名 
            "query":"明天北京到杭州的机票"        # 语言描述                                       
        }
        params = urlencode(params)
        f = urllib.urlopen(url, params)
        content = f.read()
        res = json.loads(content)
        if res:
            print(res)
        else:
            print("请求异常")