                                                            training_dir=TRAINING_DIR,
                                                            dev=True,
                                                            limit=dev_limit)
  
              print("Dev testing from file on", len(dev_data), "articles")
              print()
  
              dev_acc_combo, dev_acc_combo_dict = _measure_accuracy(dev_data)
              print("dev acc combo avg:", round(dev_acc_combo, 3),
                    [(x, round(y, 3)) for x, y in dev_acc_combo_dict.items()])
          else:
 
</s> remove             dev_acc_combo, dev_acc_combo_dict = _measure_accuracy(dev_data)
            print("dev acc combo avg:", round(dev_acc_combo, 3),
                  [(x, round(y, 3)) for x, y in dev_acc_combo_dict.items()])
        else:
            print("running toy example with NLP 3")
            run_el_toy_example(nlp=nlp_3)
 </s> add         dev_limit = 10000
        dev_data = training_set_creator.read_training(nlp=nlp_2,
                                                      training_dir=TRAINING_DIR,
                                                      dev=True,
                                                      limit=dev_limit)

        print("Dev testing from file on", len(dev_data), "articles")
        print()

        dev_acc_combo, dev_acc_combo_dict = _measure_accuracy(dev_data, el_pipe=el_pipe)
        print("dev acc combo avg:", round(dev_acc_combo, 3),
              [(x, round(y, 3)) for x, y in dev_acc_combo_dict.items()]) </s> remove         if test_from_file:
            dev_limit = 5000
            dev_data = training_set_creator.read_training(nlp=nlp_3,
                                                          training_dir=TRAINING_DIR,
                                                          dev=True,
                                                          limit=dev_limit)
 </s> add         print("running toy example with NLP 3")
        run_el_toy_example(nlp=nlp_3) </s> remove                 context_encoding = self.model([doc])
                context_enc_t = np.transpose(context_encoding)
 </s> add                 context_encoding = context_encodings[i]
                context_enc_t = context_encoding.T
                norm_1 = xp.linalg.norm(context_enc_t) </s> remove                         scores = []
                        for c in candidates:
                            prior_prob = c.prior_prob * self.prior_weight
                            kb_id = c.entity_
                            entity_encoding = c.entity_vector
                            sim = float(cosine(np.asarray([entity_encoding]), context_enc_t)) * self.context_weight
                            score = prior_prob + sim - (prior_prob*sim)
                            scores.append(score)
 </s> add                         prior_probs = xp.asarray([c.prior_prob for c in candidates])
                        prior_probs *= self.prior_weight

                        entity_encodings = xp.asarray([c.entity_vector for c in candidates])
                        norm_2 = xp.linalg.norm(entity_encodings, axis=1)

                        # cosine similarity
                        sims = xp.dot(entity_encodings, context_enc_t) / (norm_1 * norm_2)
                        sims *= self.context_weight
                        scores = prior_probs + sims - (prior_probs*sims)
                        best_index = scores.argmax() </s> remove         docs = el_pipe.pipe(docs)
 </s> add         print("applying el_pipe", datetime.datetime.now())
        docs = list(el_pipe.pipe(docs, batch_size=10000000000))
        print("done applying el_pipe", datetime.datetime.now())
    # testing performance with an NLP model from file
    if test_from_file:
        nlp_2 = spacy.load(NLP_1_DIR)
        nlp_3 = spacy.load(NLP_2_DIR)
        el_pipe = nlp_3.get_pipe("entity_linker")
                                                            training_dir=TRAINING_DIR,
                                                            dev=True,
                                                            limit=dev_limit)
  
    # testing performance with an NLP model from file
    if test_from_file:
        nlp_2 = spacy.load(NLP_1_DIR)
        nlp_3 = spacy.load(NLP_2_DIR)
        el_pipe = nlp_3.get_pipe("entity_linker")
    # testing performance with an NLP model from file
    if test_from_file:
        nlp_2 = spacy.load(NLP_1_DIR)
        nlp_3 = spacy.load(NLP_2_DIR)
        el_pipe = nlp_3.get_pipe("entity_linker")
  
              dev_acc_combo, dev_acc_combo_dict = _measure_accuracy(dev_data)
              print("dev acc combo avg:", round(dev_acc_combo, 3),
                    [(x, round(y, 3)) for x, y in dev_acc_combo_dict.items()])
          else:
keep keep keep keep replace replace keep keep keep keep keep
 improve speed of prediction loop 
examples/pipeline/wikidata_entity_linking.py