barryle
commited on
Commit
•
79eafb6
1
Parent(s):
c0768f3
AB
Browse files
app.py
CHANGED
@@ -1,7 +1,12 @@
|
|
1 |
-
from
|
|
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
tokenizer = AutoTokenizer.from_pretrained("Babelscape/wikineural-multilingual-ner")
|
5 |
+
model = AutoModelForTokenClassification.from_pretrained("Babelscape/wikineural-multilingual-ner")
|
6 |
|
7 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
|
8 |
+
example = "张伟和李娜去北京旅行。"
|
9 |
+
|
10 |
+
ner_results = nlp(example)
|
11 |
+
print(example)
|
12 |
+
print(ner_results)
|