Nawal20 commited on
Commit
5b0a5c8
·
verified ·
1 Parent(s): 210d0e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -97,6 +97,23 @@ elif input_type == "Enter Component Name":
97
  st.subheader("Simplified Summary")
98
  st.write(summary)
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  # Dynamic Table Parsing
101
  if input_type == "Upload PDF" and uploaded_file is not None and validate_pdf(uploaded_file):
102
  if st.button("Generate Key Specifications Table"):
 
97
  st.subheader("Simplified Summary")
98
  st.write(summary)
99
 
100
+
101
+ if st.button("Summarize PDF"):
102
+ # Clean and truncate text
103
+ input_text = clean_text(text[:1024])
104
+ st.text_area("Summarization Input", value=input_text, height=200)
105
+
106
+ if len(input_text.strip()) == 0:
107
+ st.error("No valid text extracted for summarization.")
108
+ else:
109
+ try:
110
+ # Summarize the text
111
+ summary = summarizer(input_text, max_length=300, min_length=50, do_sample=False)[0]["summary_text"]
112
+ st.subheader("Simplified Summary")
113
+ st.write(summary)
114
+ except Exception as e:
115
+ st.error(f"Error during summarization: {e}")
116
+
117
  # Dynamic Table Parsing
118
  if input_type == "Upload PDF" and uploaded_file is not None and validate_pdf(uploaded_file):
119
  if st.button("Generate Key Specifications Table"):