Getting KeyError when I convert json training samples to .md format
See original GitHub issueRasa version: rasa 1.4.1
Python version: Python 3.6.7
Operating system (Ubuntu):
Issue: I want to convert my json training data into .md format. My data doesn’t contain any intent, because I only want to extract entities.
Error (including full traceback):
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-7-fe8a5bb0d89a> in <module>
19
20 with open(output_md_file,'w') as f:
---> 21 f.write(load_data(input_training_file).as_markdown())
~/Documents/job_description_ner_api/env/lib/python3.6/site-packages/rasa/nlu/training_data/training_data.py in as_markdown(self)
246 )
247
--> 248 return self.nlu_as_markdown()
249
250 def persist_nlu(self, filename: Text = DEFAULT_TRAINING_DATA_OUTPUT_PATH):
~/Documents/job_description_ner_api/env/lib/python3.6/site-packages/rasa/nlu/training_data/training_data.py in nlu_as_markdown(self)
237 )
238
--> 239 return MarkdownWriter().dumps(self)
240
241 def as_markdown(self) -> Text:
~/Documents/job_description_ner_api/env/lib/python3.6/site-packages/rasa/nlu/training_data/formats/markdown.py in dumps(self, training_data)
201 """Transforms a TrainingData object into a markdown string."""
202 md = ""
--> 203 md += self._generate_training_examples_md(training_data)
204 md += self._generate_synonyms_md(training_data)
205 md += self._generate_regex_features_md(training_data)
~/Documents/job_description_ner_api/env/lib/python3.6/site-packages/rasa/nlu/training_data/formats/markdown.py in _generate_training_examples_md(self, training_data)
212 training_examples = sorted(
213 [e.as_dict_nlu() for e in training_data.training_examples],
--> 214 key=lambda k: k[MESSAGE_INTENT_ATTRIBUTE],
215 )
216 md = ""
~/Documents/job_description_ner_api/env/lib/python3.6/site-packages/rasa/nlu/training_data/formats/markdown.py in <lambda>(k)
212 training_examples = sorted(
213 [e.as_dict_nlu() for e in training_data.training_examples],
--> 214 key=lambda k: k[MESSAGE_INTENT_ATTRIBUTE],
215 )
216 md = ""
KeyError: 'intent'
Command or request that led to error:
from rasa.nlu.training_data import load_data
input_training_file = 'data/train_data/training_data.json'
output_md_file = 'data/train_data/training_data.md'
with open(output_md_file,'w') as f:
f.write(load_data(input_training_file).as_markdown())
Content of configuration file (config.yml) (if relevant):
language: "en"
pipeline:
- name: "SpacyNLP"
- name: "SpacyFeaturizer"
- name: "SpacyTokenizer"
- name: "CRFEntityExtractor"
- name: "EntitySynonymMapper"
- name: "RegexFeaturizer"
BILOU_flag: true
features: [
# Features to be extracted from token before
['low', 'title', 'upper', 'pos', 'pos2'],
# Features to be extracted from current token
['bias', 'low', 'word3', 'word2', 'upper','title', 'digit','pos', 'pos2','pattern'],
# Features to be extracted from token after
['low', 'title', 'upper', 'pos', 'pos2']]
max_iterations: 50
L1_c: 1
L2_c: 0.001
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Convert NLU from Json to markdown - Rasa Community Forum
HI All, I get the following error while i try to convert nlu data format from json into markdown. Keyerror: Intent.
Read more >Trying to parse some json but i am getting a key error - Django
I have a request that I am sending to an API and i am getting a json format response. I want to grab...
Read more >Django {json:api} training Documentation
Convert from google doc (to docx) to markdown with pandoc. ... Example: GET /api/v1/widgets?sort=-name,+qty. 6.1.4 Headers.
Read more >Python script depot - getting a KeyError when inputing key ...
Solved: I got a python score script generated by the JMP depot , When I send a dict of values (taken from a...
Read more >Experiment - Comet Docs
For example: ... Logs all the files located in the given folder as assets. ... arguments are used in the conversion to "json",...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure, it’s just the json equivalent. Wouldn’t say it’s a hack, as it’s rather the official rasa format to have
intent
as part of your example 😃This issue has been automatically closed due to inactivity. Please create a new issue if you need more help.