Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_predictions(self):
nlp = load_spacy_model()
some_text = "Jeg gik en tur med Lars"
doc = nlp(some_text)
self.assertTrue(doc.is_parsed)
self.assertTrue(doc.is_nered)
self.assertTrue(doc.is_tagged)
def benchmark_spacy_mdl():
nlp = load_spacy_model()
ner = nlp.entity
predictions = []
start = time.time()
for token in sentences_tokens:
doc = nlp.tokenizer.tokens_from_list(token)
ner(doc)
ents = []
for t in doc:
if t.ent_iob_ == 'O':
ents.append(t.ent_iob_)
else:
ents.append(t.ent_iob_ + "-" + t.ent_type_)
predictions.append(ents)