File size: 1,746 Bytes
a5008fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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()