zoukankan      html  css  js  c++  java
  • 学习笔记(12)- chatopera的语义理解系统

    参考https://github.com/chatopera/clause-py-demo

    前提:安装完毕 Docker、Docker Compose 和 Python3.x

    git clone https://github.com/chatopera/clause-py-demo.git
    cd clause-py-demo
    docker-compose pull
    

    我使用了sudo
    创新python环境,并使用

    (env) xuehp@haomeiya002:~/git/clause-py-demo$
    sudo pip3 install thrift
    sudo pip3 install absl-py
    sudo pip3 install clause
    sudo pip3 install -r requirements.txt
    export DOCKER_HOST=8056
    sudo docker-compose up
    

    等待,这样服务就运行起来了。

    注意:

    1. bot.py 是一个示例程序
    2. 加载文件profile.json,这个文件定义了一个机器人,例如:点餐机器人
    3. 处理同义词,识别意图。这些在文件profile.json中已经定义。文件见后文
    4. 和服务端交互,继续完成以下操作:训练机器人、开始对话。如下图
    5. 运行bot.py失败,ConnectionResetError: [Errno 104] Connection reset by peer
    profile.json文件,很重要。定义了一个机器人,意图、交互方式(说法)、槽位、槽值的抽取方式
    {
      "chatbotID": "bot007",
      "dicts": [
        {
          "name": "food",
          "type": "vocab",
          "dictwords": [
            {
              "word": "汉堡",
              "synonyms": "汉堡包;漢堡;漢堡包"
            },
            {
              "word": "蕃茄酱"
            }
          ]
        },
        {
          "name": "phoneNumber",
          "type": "regex",
          "patterns": ["[1]([3-9])[0-9]{9}"]
        }
      ],
      "intents": [
        {
          "name": "take_out",
          "description": "下外卖订单",
          "slots": [
            {
              "name": "time",
              "dictname": "@TIME",
              "requires": true,
              "question": "您想什么时候送到?"
            },
            {
              "name": "loc",
              "dictname": "@LOC",
              "requires": true,
              "question": "您希望该订单送到哪里?"
            },
            {
              "name": "food",
              "dictname": "food",
              "requires": true,
              "question": "您需要什么食物?"
            },
            {
              "name": "phone",
              "dictname": "phoneNumber",
              "requires": true,
              "question": "您的手机号是什么?"
            }
          ],
          "utters": [
            {
              "utterance": "我想订一份{food}"
            },
            {
              "utterance": "我想点外卖"
            },
            {
              "utterance": "我想点一份外卖,{time}用餐"
            },
            {
              "utterance": "我想点一份{food},送到{loc}"
            }
          ]
        }
      ]
    }
    
  • 相关阅读:
    solr 使用
    深入理解java虚拟机(二)HotSpot Java对象创建,内存布局以及访问方式
    深入理解java虚拟机(一)
    获取请求体数据 POST
    获取请求头数据
    Servlet之Request和Response 解析
    Servlet 之 Http协议
    Servlet 体系结构
    如何修改servlet的创建时机?
    Java Web servlet 详解
  • 原文地址:https://www.cnblogs.com/xuehuiping/p/12254674.html
Copyright © 2011-2022 走看看