有执行命令和运行代码两种方法
{
"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())
## 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())