From 408dc4acf56812d4cc2c03f573644ed821f23bff Mon Sep 17 00:00:00 2001 From: xxu2020 <7937539+xxu2020@user.noreply.gitee.com> Date: Tue, 31 Aug 2021 21:23:57 +0800 Subject: [PATCH] Add NER --- src/deepke/ner/regular/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/deepke/ner/regular/main.py diff --git a/src/deepke/ner/regular/main.py b/src/deepke/ner/regular/main.py new file mode 100644 index 0000000..f961dd1 --- /dev/null +++ b/src/deepke/ner/regular/main.py @@ -0,0 +1,20 @@ +from bert import Ner +model = Ner("out_ner/") + +text= "Irene, a master student in Zhejiang University, Hangzhou, is traveling in Warsaw for Chopin Music Festival." +print("Text to predict Entity:") +print(text) +print('Results of NER:') + +result = model.predict(text) +for k,v in result.items(): + if v: + print(v,end=': ') + if k=='PER': + print('Person') + elif k=='LOC': + print('Location') + elif k=='ORG': + print('Organization') + elif k=='MISC': + print('Miscellaneous')