yalrashed commited on
Commit
fa7b0ff
·
verified ·
1 Parent(s): e2cc090

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import os
3
  from src.processing.gemini_processor import GeminiProcessor
4
  from src.analysis.coverage_generator import CoverageGenerator
5
  from src.analysis.creative_analyzer import CreativeAnalyzer
 
6
  from pathlib import Path
7
  import logging
8
 
@@ -88,20 +89,32 @@ def analyze_screenplay(progress=gr.Progress()):
88
  logger = setup_logging(console)
89
 
90
  try:
 
91
  analyzer = CreativeAnalyzer()
92
- progress(0.5, desc="Performing creative analysis...")
93
  cleaned_path = Path("cleaned_screenplay_long.txt")
94
  success = analyzer.analyze_screenplay(cleaned_path)
95
 
96
  if not success:
97
  raise gr.Error("Failed to generate creative analysis")
98
 
99
- with open(Path("creative_analysis.txt"), 'r') as f:
 
 
 
 
 
 
 
 
 
 
100
  analysis = f.read()
101
 
102
  progress(1.0, desc="Complete!")
103
  return [analysis, console.get_output()]
104
 
 
105
  except Exception as e:
106
  error_msg = f"Error: {str(e)}"
107
  console.write(error_msg)
 
3
  from src.processing.gemini_processor import GeminiProcessor
4
  from src.analysis.coverage_generator import CoverageGenerator
5
  from src.analysis.creative_analyzer import CreativeAnalyzer
6
+ from src.analysis.analysis_post_processor import AnalysisPostProcessor
7
  from pathlib import Path
8
  import logging
9
 
 
89
  logger = setup_logging(console)
90
 
91
  try:
92
+ # Step 1: Creative Analysis
93
  analyzer = CreativeAnalyzer()
94
+ progress(0.3, desc="Performing creative analysis...")
95
  cleaned_path = Path("cleaned_screenplay_long.txt")
96
  success = analyzer.analyze_screenplay(cleaned_path)
97
 
98
  if not success:
99
  raise gr.Error("Failed to generate creative analysis")
100
 
101
+ # Step 2: Post Processing
102
+ progress(0.6, desc="Post-processing analysis...")
103
+ post_processor = AnalysisPostProcessor()
104
+ input_path = Path("creative_analysis.txt")
105
+ output_path = Path("cleaned_creative_analysis.txt")
106
+ success = post_processor.process_analysis(str(input_path), str(output_path))
107
+
108
+ if not success:
109
+ raise gr.Error("Failed to post-process analysis")
110
+
111
+ with open(output_path, 'r') as f:
112
  analysis = f.read()
113
 
114
  progress(1.0, desc="Complete!")
115
  return [analysis, console.get_output()]
116
 
117
+
118
  except Exception as e:
119
  error_msg = f"Error: {str(e)}"
120
  console.write(error_msg)