Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from utils.config import load_config | |
| from core.text_processing import TextProcessor | |
| from core.analysis import AdvancedAnalyzer | |
| from core.ui import UI | |
| def main(): | |
| # Load configuration | |
| config = load_config() | |
| # Setup UI | |
| UI.setup_page() | |
| # Initialize processors | |
| text_processor = TextProcessor(config) | |
| analyzer = AdvancedAnalyzer(config) | |
| # Sidebar configuration | |
| with st.sidebar: | |
| st.title("Analysis Settings") | |
| config['analysis']['num_topics'] = st.slider( | |
| "Number of Topics", | |
| 2, 10, | |
| config['analysis']['num_topics'] | |
| ) | |
| config['analysis']['min_entity_confidence'] = st.slider( | |
| "Entity Confidence Threshold", | |
| 0.0, 1.0, | |
| config['analysis']['min_entity_confidence'] | |
| ) | |
| # Main content | |
| st.title("Enhanced AI Output Analyzer") | |
| # Input section | |
| input_method = st.radio("Choose input method:", ["Text Input", "File Upload"]) | |
| if input_method == "File Upload": | |
| text = text_processor.process_file_upload( | |
| st.file_uploader("Upload a text file", type=['txt']) | |
| ) | |
| else: | |
| text = st.text_area("Enter text to analyze:", height=200) | |
| # Analysis section | |
| if st.button("Analyze", type="primary") and text_processor.validate_text( | |
| text, config['analysis']['max_text_length'] | |
| ): | |
| try: | |
| with st.spinner("Analyzing text..."): | |
| results = analyzer.analyze_text(text) | |
| UI.display_results(results) | |
| except Exception as e: | |
| st.error(f"An error occurred during analysis: {str(e)}") | |
| if __name__ == "__main__": | |
| main() |