barryle commited on
Commit
79eafb6
1 Parent(s): c0768f3
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,7 +1,12 @@
1
- from fastapi import FastAPI
 
2
 
3
- app = FastAPI()
 
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
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)