  
          dev_data = training_set_creator.read_training(nlp=nlp_2,
                                                        training_dir=TRAINING_DIR,
                                                        dev=True,
                                                        limit=dev_limit,
                                                        to_print=False)
  
          for itn in range(EPOCHS):
              random.shuffle(train_data)
              losses = {}
              batches = minibatch(train_data, size=compounding(4.0, 128.0, 1.001))
              batchnr = 0
  
              with nlp_2.disable_pipes(*other_pipes):
                  for batch in batches:
                      try:
                          docs, golds = zip(*batch)
                          nlp_2.update(
                              docs,
                              golds,
                              drop=DROPOUT,
                              losses=losses,
                          )
                          batchnr += 1
                      except Exception as e:
                          print("Error updating batch", e)
  
              losses['entity_linker'] = losses['entity_linker'] / batchnr
              print("Epoch, train loss", itn, round(losses['entity_linker'], 2))
  
          if measure_performance:
              print()
              print("STEP 7: performance measurement of Entity Linking pipe", datetime.datetime.now())
              print()
  
              # print(" measuring accuracy 1-1")
 
</s> remove                                                         limit=train_limit,
                                                        to_print=False)
 </s> add                                                         limit=train_limit)

        print("Training on", len(train_data), "articles")
        print()

        if not train_data:
            print("Did not find any training data")

        else:
            for itn in range(EPOCHS):
                random.shuffle(train_data)
                losses = {}
                batches = minibatch(train_data, size=compounding(4.0, 128.0, 1.001))
                batchnr = 0

                with nlp_2.disable_pipes(*other_pipes):
                    for batch in batches:
                        try:
                            docs, golds = zip(*batch)
                            nlp_2.update(
                                docs,
                                golds,
                                drop=DROPOUT,
                                losses=losses,
                            )
                            batchnr += 1
                        except Exception as e:
                            print("Error updating batch", e)

                losses['entity_linker'] = losses['entity_linker'] / batchnr
                print("Epoch, train loss", itn, round(losses['entity_linker'], 2)) </s> remove         print("Training on", train_limit, "articles")
        print("Dev testing on", dev_limit, "articles")
        print()
 </s> add  </s> remove                     gold_entities = list()
                    for ent in article_doc.ents:
                        start = ent.start_char
                        end = ent.end_char

                        entity_tuple = entries_by_offset.get(str(start) + "-" + str(end), None)
                        if entity_tuple:
                            alias, wp_title = entity_tuple
                            if ent.text != alias:
                                print("Non-matching entity in", article_id, start, end)
                            else:
                                gold_entities.append((start, end, wp_title))

                    if gold_entities:
                        gold = GoldParse(doc=article_doc, links=gold_entities)
                        data.append((article_doc, gold))

                    cnt += 1
                except Exception as e:
                    print("Problem parsing article", article_id)
                    print(e)
                    raise e

    if to_print:
        print()
        print("Processed", cnt, "training articles, dev=" + str(dev))
        print()
 </s> add  </s> remove                     entries_by_offset = entries_per_article.get(article_id, dict())
 </s> add         except Exception as e:
            print("Problem parsing article", article_id)
            print(e)
            raise e </s> remove     cnt = 0
    files = listdir(training_dir)
    for f in files:
        if not limit or cnt < limit:
            if dev == run_el.is_dev(f):
                article_id = f.replace(".txt", "")
                if cnt % 500 == 0 and to_print:
                    print(datetime.datetime.now(), "processed", cnt, "files in the training dataset")

                try:
                    # parse the article text
                    with open(os.path.join(training_dir, f), mode="r", encoding='utf8') as file:
                        text = file.read()
                        article_doc = nlp(text)
 </s> add             if gold_entities:
                gold = GoldParse(doc=article_doc, links=gold_entities)
                data.append((article_doc, gold))
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
  
          dev_data = training_set_creator.read_training(nlp=nlp_2,
                                                        training_dir=TRAINING_DIR,
                                                        dev=True,
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
                                                      limit=dev_limit)
        print("Dev testing on", len(dev_data), "articles")
        print()

        if len(dev_data) and measure_performance:
              print()
              print("STEP 7: performance measurement of Entity Linking pipe", datetime.datetime.now())
              print()
  
              # print(" measuring accuracy 1-1")
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 reprocessing all of wikipedia for training data 
examples/pipeline/wiki_entity_linking/wiki_nel_pipeline.py