NVivo_App / app.py
ahm14's picture
Rename streamlit_app.py to app.py
720b6a8 verified
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")
# Upload section
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!")
# Manual input section
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
# Translation
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.")
# Manual coding section
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)
# Keyword chart
if text_data:
keyword_chart.display_keywords(text_data)
# Theme frequency chart
if st.session_state.coded_phrases:
theme_chart.display_theme_chart(st.session_state.coded_phrases)
# LLM analysis
if text_data:
groq_analysis.show_analysis_placeholder(text_data)