def parse_analysis(self, llm_response: str) -> Optional[AnalysisResult]:
        """Main parsing method with improved validation"""
        try:
            # Clean and normalize the response
            cleaned_response = self._clean_text(llm_response)

            # Extract original question with validation
            original_question = self._extract_original_question(cleaned_response)
            if not original_question:
                self.logger.warning("Failed to extract original question")
                original_question = "Original question extraction failed"

            # Extract and validate research areas
            focus_areas = self._extract_research_areas(cleaned_response)
            focus_areas = self._normalize_focus_areas(focus_areas)

            # Calculate confidence score
            confidence_score = self._calculate_confidence_score(original_question, focus_areas)

            return AnalysisResult(
                original_question=original_question,
                focus_areas=focus_areas,
                raw_response=llm_response,
                confidence_score=confidence_score
            )

        except Exception as e:
            self.logger.error(f"Error in parse_analysis: {str(e)}")
            return None
Main parsing method with improved validation
strategic_analysis_parser.py