Rasa 트레이닝 데이터 형식 nlu.json과 nlu.md 호환

16436 단어 Python
문서 목록
  • JSON-Markdown
  • 명령 실행
  • 실행 코드
  • Markdown-JSON
  • 명령 실행
  • 실행 코드
  • -중국어
  • 참고문헌
  • 실행 명령과 실행 코드 두 가지 방법이 있어요.
    JSON - Markdown
    {
      "rasa_nlu_data": {
        "common_examples": [
          {
            "text": "hey",
            "intent": "greet",
            "entities": []
          },
          {
            "text": "hello",
            "intent": "greet",
            "entities": []
          },
          {
            "text": "i'm looking for a place in the north of town",
            "intent": "restaurant_search",
            "entities": [
              {
                "start": 31,
                "end": 36,
                "value": "north",
                "entity": "location"
              }
            ]
          },
          {
            "text": "yes",
            "intent": "affirm",
            "entities": []
          },
          {
            "text": "show me a mexican place in the centre",
            "intent": "restaurant_search",
            "entities": [
              {
                "start": 31,
                "end": 37,
                "value": "centre",
                "entity": "location"
              },
              {
                "start": 10,
                "end": 17,
                "value": "mexican",
                "entity": "cuisine"
              }
            ]
          },
          {
            "text": "bye",
            "intent": "goodbye",
            "entities": []
          },
          {
            "text": "goodbye",
            "intent": "goodbye",
            "entities": []
          },
          {
            "text": "i am looking for an indian spot",
            "intent": "restaurant_search",
            "entities": [
              {
                "start": 20,
                "end": 26,
                "value": "indian",
                "entity": "cuisine"
              }
            ]
          },
          {
            "text": "central indian restaurant",
            "intent": "restaurant_search",
            "entities": [
              {
                "start": 0,
                "end": 7,
                "value": "central",
                "entity": "location"
              },
              {
                "start": 8,
                "end": 14,
                "value": "indian",
                "entity": "cuisine"
              }
            ]
          }
        ]
      }
    }
    

    명령을 집행하다rasa data convert nlu --data data/nlu.md --out data/nlu.json -f json
    실행 코드
    from rasa.nlu.training_data import load_data
    
    input_file = 'nlu.json'
    output_file = 'nlu.md'
    
    with open(output_file, 'w') as f:
        f.write(load_data(input_file).as_markdown())
    

    Markdown - JSON
    ## intent:affirm
    - yes
    
    ## intent:goodbye
    - bye
    - goodbye
    
    ## intent:greet
    - hey
    - hello
    
    ## intent:restaurant_search
    - i'm looking for a place in the [north](location) of town
    - show me a [mexican](cuisine) place in the [centre](location)
    - i am looking for an [indian](cuisine) spot
    - [central](location) [indian](cuisine) restaurant
    

    명령을 집행하다rasa data convert nlu --data data/nlu.json --out data/nlu.md -f md
    실행 코드
    from rasa.nlu.training_data import load_data
    
    input_file = 'nlu.md'
    output_file = 'nlu.json'
    
    with open(output_file, 'w') as f:
        f.write(load_data(input_file).as_json())
    

    중국어로 바꾸다encoding='utf-8' language='zh'
    from rasa.nlu.training_data import load_data
    
    input_file = 'nlu.json'
    output_file = 'nlu.md'
    
    with open(output_file, 'w', encoding='utf-8') as f:
        f.write(load_data(input_file, language='zh').as_markdown())
    

    참고 문헌
  • Training Data Format
  • Convert a Rasa NLU training file from JSON to Markdown format
  • mmand Line Interface
  • 좋은 웹페이지 즐겨찾기