0

I have a json data set with that contains information:

{
    "text": "no of sales when it is sunny",
    "intent": "display",
    "entities": [
     {
      "start": 0,
      "end": 12,
      "value": "no of sales",
      "entity": "column"
     },
     {
      "start": 24,
      "end": 29,
      "value": "rainy",
      "entity": "filter"
     }
    ]....

I would like to turn the json file into this format:

train_data = [
("no of sales when it is sunny", {"entities": [(0, 12, "column"), (24, 29, "filter")]}),
("I like London and Berlin.", {"entities": [(7, 13, "location"), (18, 24, "location")]})
...]

but I ran into the problem when I append the tuple together: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable --NotebookApp.iopub_data_rate_limit. `.

Here is what my code looks like:

example_lst = []
count = 0
for example in common_examples_train:
    entity_tuple = ()
    entity_lst = []
    entity_dict = dict()
    whole_tuple = ()
    count += 1
    
    if(True or example['intent']=='show' or example['intent']=='showcolumns'):
        for ent in example['entities']:
            entity_tuple = (ent['start'], ent['end'], ent['entity'])
            entity_lst.append(entity_tuple)
            entity_dict = dict([('entities', entity_lst)])
    whole_tuple = (example['text'], entity_dict)
    example_lst.append(whole_tuple)
print(example_lst)

Does anyone know how to resolve the problem? Or is there a problem with my code that i should fix? Please help, thank you.

PiCubed
  • 375
  • 2
  • 5
  • 11
  • 1
    An issue similar to yours has been reported. This is an issue reported with Jupyter but still maybe some optimization can also be done [iopub data rate exceeded](https://stackoverflow.com/questions/43288550/iopub-data-rate-exceeded-in-jupyter-notebook-when-viewing-image) – Anant Kumar Aug 06 '20 at 19:53
  • That solved the problem. Thank you – PiCubed Aug 07 '20 at 16:14

0 Answers0