Spaces:
Runtime error
Runtime error
Commit
•
1995421
1
Parent(s):
c6ec32d
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,23 @@ model = AutoModelForTokenClassification.from_pretrained("d4data/biomedical-ner-a
|
|
19 |
|
20 |
biomed_ner_pipe = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple") # pass device=0 if using gpu
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
def translate_and_classify(audio):
|
24 |
|
25 |
print("""
|
@@ -44,8 +60,7 @@ def translate_and_classify(audio):
|
|
44 |
print("Transcript: " + transcription.text)
|
45 |
print("Translated: " + translation.text)
|
46 |
|
47 |
-
|
48 |
-
detected_ner = result
|
49 |
print("Detected Named Entities: ", detected_ner)
|
50 |
return transcription.text, detected_ner
|
51 |
|
|
|
19 |
|
20 |
biomed_ner_pipe = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple") # pass device=0 if using gpu
|
21 |
|
22 |
+
def parse_ber(text):
|
23 |
+
raw = biomed_ner_pipe(text)
|
24 |
+
ner_content = {
|
25 |
+
"text": text,
|
26 |
+
"entities": [
|
27 |
+
{
|
28 |
+
"entity": x["entity_group"],
|
29 |
+
"word": x["word"],
|
30 |
+
"score": x["score"],
|
31 |
+
"start": x["start"],
|
32 |
+
"end": x["end"],
|
33 |
+
}
|
34 |
+
for x in raw
|
35 |
+
]
|
36 |
+
}
|
37 |
+
return ner_content
|
38 |
+
|
39 |
def translate_and_classify(audio):
|
40 |
|
41 |
print("""
|
|
|
60 |
print("Transcript: " + transcription.text)
|
61 |
print("Translated: " + translation.text)
|
62 |
|
63 |
+
detected_ner = parse_ner(translation.text)
|
|
|
64 |
print("Detected Named Entities: ", detected_ner)
|
65 |
return transcription.text, detected_ner
|
66 |
|