Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -113,15 +113,23 @@ def main():
|
|
113 |
|
114 |
requirements = []
|
115 |
if input_option == "Enter Requirements":
|
116 |
-
input_text = st.text_area("Enter your requirements (one per line):")
|
117 |
if input_text:
|
118 |
-
|
|
|
119 |
else:
|
120 |
uploaded_file = st.file_uploader("Upload a PDF file:", type="pdf")
|
121 |
if uploaded_file:
|
122 |
-
|
123 |
-
|
124 |
-
requirements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
# Analyze requirements
|
127 |
if st.button("Analyze Requirements"):
|
|
|
113 |
|
114 |
requirements = []
|
115 |
if input_option == "Enter Requirements":
|
116 |
+
input_text = st.text_area("Enter your requirements (one per line or separated by periods):")
|
117 |
if input_text:
|
118 |
+
# Split by periods or newlines
|
119 |
+
requirements = [req.strip() for req in input_text.replace("\n", ".").split(".") if req.strip()]
|
120 |
else:
|
121 |
uploaded_file = st.file_uploader("Upload a PDF file:", type="pdf")
|
122 |
if uploaded_file:
|
123 |
+
try:
|
124 |
+
with pdfplumber.open(uploaded_file) as pdf:
|
125 |
+
requirements = []
|
126 |
+
for page in pdf.pages:
|
127 |
+
text = page.extract_text()
|
128 |
+
if text:
|
129 |
+
# Split by periods or newlines
|
130 |
+
requirements.extend([req.strip() for req in text.replace("\n", ".").split(".") if req.strip()])
|
131 |
+
except Exception as e:
|
132 |
+
st.error(f"Error reading PDF file: {e}")
|
133 |
|
134 |
# Analyze requirements
|
135 |
if st.button("Analyze Requirements"):
|