Update app.py
Browse files
app.py
CHANGED
|
@@ -407,39 +407,43 @@ def extract_text_from_pdf(pdf_file):
|
|
| 407 |
st.error(f"Error extracting text from PDF: {str(e)}")
|
| 408 |
return ""
|
| 409 |
|
| 410 |
-
|
| 411 |
def main():
|
| 412 |
st.set_page_config(page_title="Chemistry Text Analyzer", page_icon="🧪", layout="wide")
|
| 413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
st.title("Chemistry Text Analyzer")
|
| 415 |
st.write("""
|
| 416 |
This app analyzes chemistry text for common errors, inconsistencies, and formatting issues.
|
| 417 |
Upload a PDF file or paste your text in the box below to analyze it.
|
| 418 |
""")
|
| 419 |
-
|
| 420 |
# Create tabs for different input methods
|
| 421 |
tab1, tab2 = st.tabs(["Upload PDF", "Text Input"])
|
| 422 |
-
|
| 423 |
with tab1:
|
| 424 |
uploaded_file = st.file_uploader("Choose a PDF file", type=['pdf'])
|
| 425 |
analyze_pdf = st.button("Analyze PDF")
|
| 426 |
-
|
| 427 |
if analyze_pdf and uploaded_file is not None:
|
| 428 |
with st.spinner("Extracting text from PDF..."):
|
| 429 |
text_content = extract_text_from_pdf(uploaded_file)
|
| 430 |
-
|
| 431 |
if text_content:
|
| 432 |
st.success(f"Successfully extracted text from {uploaded_file.name}")
|
| 433 |
st.write("---")
|
| 434 |
analyze_content(text_content)
|
| 435 |
else:
|
| 436 |
st.error("Failed to extract text from the PDF. Please check if the PDF contains extractable text.")
|
| 437 |
-
|
| 438 |
with tab2:
|
| 439 |
# Text input area
|
| 440 |
text_input = st.text_area("Paste your text here:", height=300)
|
| 441 |
analyze_text = st.button("Analyze Text")
|
| 442 |
-
|
| 443 |
if analyze_text:
|
| 444 |
if not text_input:
|
| 445 |
st.warning("Please paste some text to analyze.")
|
|
@@ -449,7 +453,6 @@ def main():
|
|
| 449 |
text_content = text_input.replace('\n', ' ')
|
| 450 |
analyze_content(text_content)
|
| 451 |
|
| 452 |
-
|
| 453 |
def analyze_content(text_content):
|
| 454 |
"""
|
| 455 |
Analyze the text content and display results.
|
|
|
|
| 407 |
st.error(f"Error extracting text from PDF: {str(e)}")
|
| 408 |
return ""
|
| 409 |
|
|
|
|
| 410 |
def main():
|
| 411 |
st.set_page_config(page_title="Chemistry Text Analyzer", page_icon="🧪", layout="wide")
|
| 412 |
+
st.markdown(
|
| 413 |
+
"""
|
| 414 |
+
<style>
|
| 415 |
+
div.block-container {
|
| 416 |
+
overflow-y: auto !important;
|
| 417 |
+
}
|
| 418 |
+
iframe {
|
| 419 |
+
overflow: visible !important;
|
| 420 |
+
}
|
| 421 |
+
</style>
|
| 422 |
+
""", unsafe_allow_html=True
|
| 423 |
+
)
|
| 424 |
st.title("Chemistry Text Analyzer")
|
| 425 |
st.write("""
|
| 426 |
This app analyzes chemistry text for common errors, inconsistencies, and formatting issues.
|
| 427 |
Upload a PDF file or paste your text in the box below to analyze it.
|
| 428 |
""")
|
|
|
|
| 429 |
# Create tabs for different input methods
|
| 430 |
tab1, tab2 = st.tabs(["Upload PDF", "Text Input"])
|
|
|
|
| 431 |
with tab1:
|
| 432 |
uploaded_file = st.file_uploader("Choose a PDF file", type=['pdf'])
|
| 433 |
analyze_pdf = st.button("Analyze PDF")
|
|
|
|
| 434 |
if analyze_pdf and uploaded_file is not None:
|
| 435 |
with st.spinner("Extracting text from PDF..."):
|
| 436 |
text_content = extract_text_from_pdf(uploaded_file)
|
|
|
|
| 437 |
if text_content:
|
| 438 |
st.success(f"Successfully extracted text from {uploaded_file.name}")
|
| 439 |
st.write("---")
|
| 440 |
analyze_content(text_content)
|
| 441 |
else:
|
| 442 |
st.error("Failed to extract text from the PDF. Please check if the PDF contains extractable text.")
|
|
|
|
| 443 |
with tab2:
|
| 444 |
# Text input area
|
| 445 |
text_input = st.text_area("Paste your text here:", height=300)
|
| 446 |
analyze_text = st.button("Analyze Text")
|
|
|
|
| 447 |
if analyze_text:
|
| 448 |
if not text_input:
|
| 449 |
st.warning("Please paste some text to analyze.")
|
|
|
|
| 453 |
text_content = text_input.replace('\n', ' ')
|
| 454 |
analyze_content(text_content)
|
| 455 |
|
|
|
|
| 456 |
def analyze_content(text_content):
|
| 457 |
"""
|
| 458 |
Analyze the text content and display results.
|