Spaces:
Build error
Build error
Update Summarization_Simple_25Nov.py
Browse files- Summarization_Simple_25Nov.py +15 -24
Summarization_Simple_25Nov.py
CHANGED
@@ -5,6 +5,11 @@ from math import ceil
|
|
5 |
from collections import Counter
|
6 |
from string import punctuation
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
#nlp = en_core_web_lg.load()
|
9 |
|
10 |
st.set_page_config(layout='wide')
|
@@ -85,31 +90,17 @@ def run_model(input_text):
|
|
85 |
st.write('Summary')
|
86 |
st.success(output)
|
87 |
|
88 |
-
if st.button('
|
89 |
run_model(runtext)
|
90 |
|
91 |
sentences=runtext.split('.')
|
92 |
-
|
93 |
-
text = ''
|
94 |
-
|
95 |
-
#display(HTML(f'<h1>Summary - {title}</h1>'))
|
96 |
-
for sentence in sentence_list:
|
97 |
-
if sentence in best_sentences:
|
98 |
-
#text += ' ' + str(sentence).replace(sentence, f"<mark>{sentence}</mark>")
|
99 |
-
text += ' ' + str(sentence).replace(sentence, f"<span class='highlight yellow'>{sentence}</span>")
|
100 |
-
else:
|
101 |
-
text += ' ' + sentence
|
102 |
-
display(HTML(f""" {text} """))
|
103 |
-
|
104 |
-
output = ''
|
105 |
-
best_sentences = []
|
106 |
-
for sentence in output:
|
107 |
-
#print(sentence)
|
108 |
-
best_sentences.append(str(sentence))
|
109 |
-
return text
|
110 |
-
|
111 |
-
t = "<div>Hello there my <span class='highlight blue'>name <span class='bold'>yo</span> </span> is <span class='highlight red'>Fanilo <span class='bold'>Name</span></span></div>"
|
112 |
-
|
113 |
-
st.write("<div>Hello there my <span class='highlight blue'>name <span class='bold'>yo</span> </span> is <span class='highlight red'>Fanilo <span class='bold'>Name</span></span></div>")
|
114 |
|
115 |
-
st.text_area('Reference text', str(reference_text))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from collections import Counter
|
6 |
from string import punctuation
|
7 |
|
8 |
+
import spacy
|
9 |
+
from spacy import displacy
|
10 |
+
import en_ner_bc5cdr_md
|
11 |
+
|
12 |
+
nlp = spacy.load("en_ner_bc5cdr_md")
|
13 |
#nlp = en_core_web_lg.load()
|
14 |
|
15 |
st.set_page_config(layout='wide')
|
|
|
90 |
st.write('Summary')
|
91 |
st.success(output)
|
92 |
|
93 |
+
if st.button('Summarize'):
|
94 |
run_model(runtext)
|
95 |
|
96 |
sentences=runtext.split('.')
|
97 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
+
st.text_area('Reference text', str(reference_text))
|
100 |
+
|
101 |
+
if st.button('NER'):
|
102 |
+
doc = nlp(str(original_text2))
|
103 |
+
colors = { "DISEASE": "pink","CHEMICAL": "orange"}
|
104 |
+
options = {"ents": [ "DISEASE", "CHEMICAL"],"colors": colors}
|
105 |
+
ent_html = displacy.render(doc, style="ent", options=options)
|
106 |
+
st.markdown(ent_html, unsafe_allow_html=True)
|