Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rasa NLU training data migrator from JSON format to Markdown
import json
from pprint import pprint
from collections import defaultdict
from pathlib import Path
def main():
path = Path("./data.json").resolve()
with as f:
content = json.load(f)
lookup = {
"intents": defaultdict(list),
"synonyms": defaultdict(list)
content = content['rasa_nlu_data']['common_examples']
for item in content:
intent = item['intent']
text = item['text']
for entity in reversed(item['entities']):
text = text.replace(entity['value'], f"[{entity['value']}]({entity['entity']})")
for intent, words in lookup['intents'].items():
print(f"## intent:{intent}")
[print(f"- {text}") for text in words]
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.