File size: 528 Bytes
c19cf37
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
from transformers import BertTokenizer, AutoModelForTokenClassification
from transformers import pipeline

tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
model = AutoModelForTokenClassification.from_pretrained("ctrlbuzz/bert-addresses")
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
example = "While Maria was representing Johnson & Associates at a conference in Spain, she mailed me a letter from her new office at 123 Elm St., Apt. 4B, Springfield, IL.",


ner_results = nlp(example)
print(ner_results)