Spaces:
Sleeping
Sleeping
File size: 938 Bytes
b8d5d36 ea2d73a 844bbbd b8d5d36 844bbbd b8d5d36 844bbbd b8d5d36 844bbbd b8d5d36 844bbbd b8d5d36 844bbbd b8d5d36 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import spacy
import pytextrank
import streamlit as st
# Load NLP model and add TextRank once
nlp = spacy.load("en_core_web_lg")
nlp.add_pipe("textrank")
def summarize_text(input_text):
doc = nlp(input_text)
summary = "\n".join([f"• {sent.text}" for sent in doc._.textrank.summary(limit_phrases=2, limit_sentences=2)])
return summary
def main():
st.title("TextRank Text Summarizer")
st.write("This app generates a concise summary from your input text using TextRank.")
input_text = st.text_area("Enter the text you want to summarize:", height=300)
if st.button("Summarize"):
if input_text.strip():
with st.spinner("Generating summary..."):
summary = summarize_text(input_text)
st.subheader("Summary:")
st.write(summary)
else:
st.warning("Please enter some text to summarize.")
if __name__ == "__main__":
main()
|