def _identify_focus_areas(self) -> List[str]: """Identify areas that need more attention based on complexity markers""" complexity_markers = [ 'important', 'crucial', 'essential', 'note that', 'remember', 'key point', 'significant', 'critical', 'fundamental' ] focus_areas = [] sentences = sent_tokenize(self.full_text) for sentence in sentences: for marker in complexity_markers: if marker in sentence.lower(): focus_areas.append(sentence[:100]) break return list(set(focus_areas))[:8]
def export_to_json(self, output_path: str): """Export all analysis results to JSON file""" output = 'metadata': 'source_file': self.pdf_path, 'total_pages': len(self.pages_text), 'total_words': len(self.full_text.split()) , 'summary': self.create_summary(), 'sections': self.sections, 'key_concepts': self.key_concepts, 'case_studies': self.case_studies, 'study_questions': self.generate_study_questions(), 'full_text_excerpt': self.full_text[:5000] # First 5000 chars with open(output_path, 'w', encoding='utf-8') as f: json.dump(output, f, indent=2, ensure_ascii=False) print(f"Analysis exported to output_path") class UrbanPlanningStudyAssistant: def init (self, analyzer: UrbanPlanningNotesAnalyzer): self.analyzer = analyzer urban planning lecture notes pdf
def create_summary(self) -> Dict: """Create a structured summary of the lecture notes""" summary = 'total_pages': len(self.pages_text), 'total_words': len(self.full_text.split()), 'key_topics': [c['term'] for c in self.key_concepts[:15]], 'case_studies_count': len(self.case_studies), 'main_sections': list(self.sections.keys())[:10], 'core_principles': self._extract_principles(), 'recommended_focus_areas': self._identify_focus_areas() return summary def _identify_focus_areas(self) ->
def generate_study_questions(self) -> List[Dict]: """Generate study questions based on key concepts and sections""" questions = [] # Generate questions from key concepts for concept in self.key_concepts[:10]: questions.append( 'type': 'concept', 'question': f"What are the key principles and applications of concept['term'] in urban planning?", 'related_concept': concept['term'], 'hint': f"Review section discussing concept['term'] (mentioned concept['frequency'] times)" ) # Generate questions from sections for section_name, section_text in list(self.sections.items())[:5]: if len(section_text) > 100: questions.append( 'type': 'section', 'question': f"Summarize the main arguments presented in 'section_name' regarding urban planning approaches.", 'related_section': section_name, 'hint': "Focus on the key definitions and examples provided" ) # Add comparative questions if len(self.case_studies) >= 2: questions.append( 'type': 'comparative', 'question': f"Compare and contrast the urban planning approaches in 'self.case_studies[0]['title']' vs 'self.case_studies[1]['title']'.", 'hint': "Consider differences in context, implementation, and outcomes" ) return questions encoding='utf-8') as f: json.dump(output
def interactive_session(self): """Run interactive study session""" print("\n" + "="*60) print("š URBAN PLANNING STUDY ASSISTANT") print("="*60) print("\nCommands:") print(" 'concepts' - Show key concepts") print(" 'questions' - Generate study questions") print(" 'cases' - Show case studies") print(" 'summary' - Show lecture summary") print(" 'search [term]' - Search for specific topics") print(" 'quiz' - Take a quick quiz") print(" 'export' - Export analysis to JSON") print(" 'quit' - Exit") while True: command = input("\nš Enter command: ").strip().lower() if command == 'quit': print("Happy studying! š") break elif command == 'concepts': self._show_concepts() elif command == 'questions': self._show_questions() elif command == 'cases': self._show_case_studies() elif command == 'summary': self._show_summary() elif command.startswith('search'): term = command[7:].strip() if term: self._search(term) else: print("Please provide a search term (e.g., 'search zoning')") elif command == 'quiz': self._take_quiz() elif command == 'export': self.analyzer.export_to_json('urban_planning_analysis.json') else: print("Unknown command. Try 'concepts', 'questions', 'cases', 'summary', 'search [term]', 'quiz', or 'quit'")
def _show_summary(self): summary = self.analyzer.create_summary() print("\nš LECTURE SUMMARY:") print(f" Pages: summary['total_pages']") print(f" Total Words: summary['total_words']:,") print(f" Case Studies: summary['case_studies_count']") print(f"\n Main Topics: ', '.join(summary['key_topics'][:10])") print(f"\n Key Sections: ', '.join(summary['main_sections'][:5])")