pustozerov
commited on
Commit
·
075ef09
1
Parent(s):
b3d7e5c
Modified NER output to the output+summary style.
Browse files- modules/nlp/nemo_ner.py +4 -5
modules/nlp/nemo_ner.py
CHANGED
@@ -10,8 +10,7 @@ pretrained_ner_model = nemo_nlp.models.TokenClassificationModel.from_pretrained(
|
|
10 |
|
11 |
|
12 |
def detect_ner(input_string):
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
return output_string
|
|
|
10 |
|
11 |
|
12 |
def detect_ner(input_string):
|
13 |
+
tagged_string = pretrained_ner_model.add_predictions([input_string.replace('[', '').replace(']', '')])[0]
|
14 |
+
tags = re.findall('\[.*?]', tagged_string)
|
15 |
+
tags_summary = "Found named entities: " + str(dict(Counter(tags)))[1:-1]
|
16 |
+
return tagged_string, tags_summary
|
|