добавление кортежа в список - превышена скорость передачи данных IOPub - PullRequest
0 голосов
/ 06 августа 2020

У меня есть набор данных json, содержащий информацию:

{
    "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"
     }
    ]....

Я хотел бы преобразовать файл json в этот формат:

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")]})
...]

но я столкнулся с проблемой, когда я добавил кортеж вместе: 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. `.

Вот как выглядит мой код:

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)

Кто-нибудь знает, как решить проблему? Или есть проблема с моим кодом, которую я должен исправить? Пожалуйста, помогите, спасибо.

...