Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
model_checkpoint = "Shubham555/biobert-finetuned-ner"
|
6 |
+
token_classifier = pipeline("token-classification", model=model_checkpoint, aggregation_strategy="simple")
|
7 |
+
|
8 |
+
|
9 |
+
examples = [
|
10 |
+
["Clustering of missense mutations in the ataxia - telangiectasia gene in a sporadic T - cell leukaemia."],
|
11 |
+
["Ataxia - telangiectasia ( A - T ) is a recessive multi - system disorder caused by mutations in the ATM gene at 11q22 - q23 ( ref . 3 )."],
|
12 |
+
["The risk of cancer , especially lymphoid neoplasias , is substantially elevated in A - T patients and has long been associated with chromosomal instability."],
|
13 |
+
["These clustered in the region corresponding to the kinase domain , which is highly conserved in ATM - related proteins in mouse , yeast and Drosophila."],
|
14 |
+
["Constitutional RB1 - gene mutations in patients with isolated unilateral retinoblastoma ."],
|
15 |
+
["The evidence of a significant proportion of loss - of - function mutations and a complete absence of the normal copy of ATM in the majority of mutated tumours establishes somatic inactivation of this gene in the pathogenesis of sporadic T - PLL and suggests that ATM acts as a tumour suppressor."],
|
16 |
+
]
|
17 |
+
|
18 |
+
|
19 |
+
def ner(text):
|
20 |
+
output = token_classifier(text)
|
21 |
+
for hmap in output:
|
22 |
+
hmap['entity'] = hmap['entity_group']
|
23 |
+
del hmap['entity_group']
|
24 |
+
return {"text": text, "entities": output}
|
25 |
+
|
26 |
+
demo = gr.Interface(ner,
|
27 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
28 |
+
gr.HighlightedText(),
|
29 |
+
examples=examples,
|
30 |
+
allow_flagging = 'never',
|
31 |
+
title="Named Entity Recognition for Disease Identification",
|
32 |
+
description="The app uses BioBERT finetuned on NCBI Dataset and can be used to detect the name of diseases appearing in the given text")
|
33 |
+
|
34 |
+
demo.launch()
|