sharath6900 commited on
Commit
7f33eef
·
verified ·
1 Parent(s): 35d8013

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -16,12 +16,15 @@ def generate_summary(text):
16
  return important_points
17
 
18
  def extract_important_points(summary):
19
- # This is a very basic example of how you might filter for key phrases
20
- # You can refine this with more sophisticated NLP techniques
21
  keywords = ["change", "request", "important", "needs", "must", "critical", "required", "suggested"]
22
  filtered_lines = [line for line in summary.split('. ') if any(keyword in line.lower() for keyword in keywords)]
23
  return '. '.join(filtered_lines)
24
 
 
 
 
 
25
  # Streamlit interface
26
  st.title("Text Summarization App")
27
 
@@ -32,10 +35,22 @@ if st.button("Generate Summary"):
32
  if user_input:
33
  with st.spinner("Generating summary..."):
34
  summary = generate_summary(user_input)
 
 
 
 
35
  st.subheader("Filtered Summary:")
36
  st.write(summary)
37
  else:
38
  st.warning("Please enter text to summarize.")
39
 
 
 
 
 
 
 
 
 
40
  # Instructions for using the app
41
  st.write("Enter your text in the box above and click 'Generate Summary' to get a summarized version of your text.")
 
16
  return important_points
17
 
18
  def extract_important_points(summary):
19
+ # Filter the summary for sentences containing keywords related to change requests or important points
 
20
  keywords = ["change", "request", "important", "needs", "must", "critical", "required", "suggested"]
21
  filtered_lines = [line for line in summary.split('. ') if any(keyword in line.lower() for keyword in keywords)]
22
  return '. '.join(filtered_lines)
23
 
24
+ # Initialize session state for input history if it doesn't exist
25
+ if 'input_history' not in st.session_state:
26
+ st.session_state['input_history'] = []
27
+
28
  # Streamlit interface
29
  st.title("Text Summarization App")
30
 
 
35
  if user_input:
36
  with st.spinner("Generating summary..."):
37
  summary = generate_summary(user_input)
38
+
39
+ # Save the input and summary to the session state history
40
+ st.session_state['input_history'].append({"input": user_input, "summary": summary})
41
+
42
  st.subheader("Filtered Summary:")
43
  st.write(summary)
44
  else:
45
  st.warning("Please enter text to summarize.")
46
 
47
+ # Display the history of inputs and summaries
48
+ if st.session_state['input_history']:
49
+ st.subheader("History")
50
+ for i, entry in enumerate(st.session_state['input_history']):
51
+ st.write(f"**Input {i+1}:** {entry['input']}")
52
+ st.write(f"**Summary {i+1}:** {entry['summary']}")
53
+ st.write("---")
54
+
55
  # Instructions for using the app
56
  st.write("Enter your text in the box above and click 'Generate Summary' to get a summarized version of your text.")