Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
944 views
in Technique[技术] by (71.8m points)

yaml - special characters in yalm.dump python

I'm trying to save a file in yaml format with

with open('data.yml', 'w') as outfile:
   yaml.dump(data, outfile, default_flow_style=False)

with data, a dictionary with this format:

data={"## intent:greet": ["hi", "hello" ... "hola"], "## intent:goodbye": [...]}

in order to use it as nlu in a rasa development. The problem is that yalm.dump does not save the keys in an appropriate way because of the ## character. it saves the file as

'## intent:greet':
- hi
- hello

instead of

## intent:greet
- hi
- hello

What could be the way to solve the ' ' characters and delete the : in key (## intent:AAA) row??

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are trying to generate a Markdown file with a YAML processor. That isn't going to work.

Mind that Rasa 1.x used the Markdown format, which used ## intent:greet as heading, while Rasa 2.x uses a YAML format, which looks differently. You either use the 1.x Markdown format or YAML. You cannot generate the 1.x format with a YAML processor.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...