File size: 447 Bytes
537dfb9
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import spacy
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline

# Load SpaCy model
nlp_spacy = spacy.load('en_core_web_sm')

# Load NER model
tokenizer = AutoTokenizer.from_pretrained("Babelscape/wikineural-multilingual-ner")
model = AutoModelForTokenClassification.from_pretrained("Babelscape/wikineural-multilingual-ner")
nlp_ner = pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy="simple")