| import streamlit as st |
| from components import keyword_chart, theme_chart, groq_analysis, translator |
| from utils import file_loader, export |
|
|
| st.set_page_config(page_title="Qualitative Coding Tool", layout="wide") |
| st.title("π§ AI-Powered Qualitative Coding App") |
|
|
| |
| uploaded_file = st.file_uploader("π Upload DOCX, PDF, or TXT", type=["pdf", "txt", "docx"]) |
| text_data = "" |
|
|
| if uploaded_file: |
| text_data = file_loader.extract_text(uploaded_file) |
| st.success("File loaded successfully!") |
|
|
| |
| st.subheader("βοΈ Manual Caption Input") |
| manual_input = st.text_area("Enter or paste captions directly here:", height=200) |
|
|
| if manual_input: |
| text_data = manual_input |
|
|
| |
| if text_data: |
| if st.checkbox("π Translate text to English (if non-English)"): |
| text_data = translator.translate_text(text_data) |
| st.info("Translated to English.") |
|
|
| |
| st.subheader("π Manual Coding") |
| code_input = st.text_input("Enter a code (e.g. advocacy, inclusivity):") |
| selected_text = st.text_area("Paste a phrase to code:", height=150) |
|
|
| if "coded_phrases" not in st.session_state: |
| st.session_state.coded_phrases = [] |
|
|
| if st.button("Add Code"): |
| if selected_text and code_input: |
| st.session_state.coded_phrases.append({"phrase": selected_text, "code": code_input}) |
| st.success("Code added!") |
|
|
| if st.session_state.coded_phrases: |
| export.display_and_download(st.session_state.coded_phrases) |
|
|
| |
| if text_data: |
| keyword_chart.display_keywords(text_data) |
|
|
| |
| if st.session_state.coded_phrases: |
| theme_chart.display_theme_chart(st.session_state.coded_phrases) |
|
|
| |
| if text_data: |
| groq_analysis.show_analysis_placeholder(text_data) |