Spaces:
Runtime error
Runtime error
Update app.py
Browse filesrispristinate everything
app.py
CHANGED
|
@@ -23,6 +23,14 @@ if __name__ == "__main__":
|
|
| 23 |
"Summarization type", options=["Extractive", "Abstractive"]
|
| 24 |
)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
st.markdown("---")
|
| 27 |
# ---------------------------
|
| 28 |
# SETUP & Constants
|
|
@@ -34,17 +42,31 @@ if __name__ == "__main__":
|
|
| 34 |
abs_min_length = 30
|
| 35 |
# ---------------------------
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
uploaded_file = st.file_uploader(
|
| 38 |
"Upload a .txt, .pdf, .docx file for summarization"
|
| 39 |
)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# view summarized text (expander)
|
| 46 |
with st.expander("View input text"):
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
summarize = st.button("Summarize")
|
| 49 |
|
| 50 |
# called on toggle button [summarize]
|
|
|
|
| 23 |
"Summarization type", options=["Extractive", "Abstractive"]
|
| 24 |
)
|
| 25 |
|
| 26 |
+
st.markdown(
|
| 27 |
+
"Enter a text or a url to get a concise summary of the article while conserving the overall meaning. This app supports text in the following formats:"
|
| 28 |
+
)
|
| 29 |
+
st.markdown(
|
| 30 |
+
"""- Raw text in text box
|
| 31 |
+
- URL of article/news to be summarized
|
| 32 |
+
- .txt, .pdf, .docx file formats"""
|
| 33 |
+
)
|
| 34 |
st.markdown("---")
|
| 35 |
# ---------------------------
|
| 36 |
# SETUP & Constants
|
|
|
|
| 42 |
abs_min_length = 30
|
| 43 |
# ---------------------------
|
| 44 |
|
| 45 |
+
inp_text = st.text_input("Enter text or a url here")
|
| 46 |
+
st.markdown(
|
| 47 |
+
"<h3 style='text-align: center; color: green;'>OR</h3>",
|
| 48 |
+
unsafe_allow_html=True,
|
| 49 |
+
)
|
| 50 |
uploaded_file = st.file_uploader(
|
| 51 |
"Upload a .txt, .pdf, .docx file for summarization"
|
| 52 |
)
|
| 53 |
|
| 54 |
+
is_url = validators.url(inp_text)
|
| 55 |
+
if is_url:
|
| 56 |
+
# complete text, chunks to summarize (list of sentences for long docs)
|
| 57 |
+
text, clean_txt = fetch_article_text(url=inp_text)
|
| 58 |
+
elif uploaded_file:
|
| 59 |
+
clean_txt = read_text_from_file(uploaded_file)
|
| 60 |
+
clean_txt = clean_text(clean_txt)
|
| 61 |
+
else:
|
| 62 |
+
clean_txt = clean_text(inp_text)
|
| 63 |
|
| 64 |
# view summarized text (expander)
|
| 65 |
with st.expander("View input text"):
|
| 66 |
+
if is_url:
|
| 67 |
+
st.write(clean_txt[0])
|
| 68 |
+
else:
|
| 69 |
+
st.write(clean_txt)
|
| 70 |
summarize = st.button("Summarize")
|
| 71 |
|
| 72 |
# called on toggle button [summarize]
|