shaheerawan3 commited on
Commit
a5008fc
·
verified ·
1 Parent(s): a2e1046

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +58 -0
main.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.config import load_config
3
+ from core.text_processing import TextProcessor
4
+ from core.analysis import AdvancedAnalyzer
5
+ from core.ui import UI
6
+
7
+ def main():
8
+ # Load configuration
9
+ config = load_config()
10
+
11
+ # Setup UI
12
+ UI.setup_page()
13
+
14
+ # Initialize processors
15
+ text_processor = TextProcessor(config)
16
+ analyzer = AdvancedAnalyzer(config)
17
+
18
+ # Sidebar configuration
19
+ with st.sidebar:
20
+ st.title("Analysis Settings")
21
+ config['analysis']['num_topics'] = st.slider(
22
+ "Number of Topics",
23
+ 2, 10,
24
+ config['analysis']['num_topics']
25
+ )
26
+ config['analysis']['min_entity_confidence'] = st.slider(
27
+ "Entity Confidence Threshold",
28
+ 0.0, 1.0,
29
+ config['analysis']['min_entity_confidence']
30
+ )
31
+
32
+ # Main content
33
+ st.title("Enhanced AI Output Analyzer")
34
+
35
+ # Input section
36
+ input_method = st.radio("Choose input method:", ["Text Input", "File Upload"])
37
+
38
+ if input_method == "File Upload":
39
+ text = text_processor.process_file_upload(
40
+ st.file_uploader("Upload a text file", type=['txt'])
41
+ )
42
+ else:
43
+ text = st.text_area("Enter text to analyze:", height=200)
44
+
45
+ # Analysis section
46
+ if st.button("Analyze", type="primary") and text_processor.validate_text(
47
+ text, config['analysis']['max_text_length']
48
+ ):
49
+ try:
50
+ with st.spinner("Analyzing text..."):
51
+ results = analyzer.analyze_text(text)
52
+ UI.display_results(results)
53
+
54
+ except Exception as e:
55
+ st.error(f"An error occurred during analysis: {str(e)}")
56
+
57
+ if __name__ == "__main__":
58
+ main()