Natwar commited on
Commit
93aaa5c
Β·
verified Β·
1 Parent(s): b184a4a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +1169 -0
app.py ADDED
@@ -0,0 +1,1169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Untitled23.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1B696PzN1xnipZQ6zfEJqphJFVadAYh3B
8
+ """
9
+
10
+ """"
11
+ Complete Standalone Resume Matcher for Google Colab
12
+ No external dependencies required - just paste and run!
13
+ """
14
+
15
+ import gradio as gr
16
+ import json
17
+ import re
18
+ from datetime import datetime
19
+ from typing import Tuple, List, Dict, Any
20
+ from collections import Counter
21
+ import math
22
+
23
+ class TextProfileParser:
24
+ """Simple text profile parser."""
25
+
26
+ def parse(self, profile_text: str) -> Dict:
27
+ """Parse profile text into structured data."""
28
+ sections = {
29
+ "education": [],
30
+ "experience": [],
31
+ "skills": [],
32
+ "projects": [],
33
+ "achievements": [],
34
+ "certificates": []
35
+ }
36
+
37
+ lines = profile_text.split('\n')
38
+ current_section = None
39
+
40
+ for line in lines:
41
+ line = line.strip()
42
+ if not line:
43
+ continue
44
+
45
+ # Detect section headers
46
+ line_lower = line.lower()
47
+ if any(keyword in line_lower for keyword in ['education', 'academic']):
48
+ current_section = 'education'
49
+ elif any(keyword in line_lower for keyword in ['experience', 'work', 'employment']):
50
+ current_section = 'experience'
51
+ elif any(keyword in line_lower for keyword in ['skill', 'technical', 'competenc']):
52
+ current_section = 'skills'
53
+ elif any(keyword in line_lower for keyword in ['project', 'portfolio']):
54
+ current_section = 'projects'
55
+ elif any(keyword in line_lower for keyword in ['achievement', 'award', 'honor', 'certificate']):
56
+ current_section = 'achievements'
57
+ elif current_section and line:
58
+ sections[current_section].append(line)
59
+
60
+ return sections
61
+
62
+ class StandaloneResumeMatcherApp:
63
+ """Complete standalone resume matcher with no external dependencies."""
64
+
65
+ def __init__(self):
66
+ print("Initializing Standalone Resume Matcher for Google Colab...")
67
+
68
+ # Initialize basic components
69
+ self.text_profile_parser = TextProfileParser()
70
+
71
+ # Create comprehensive role database
72
+ self.role_database = self._create_comprehensive_role_database()
73
+
74
+ # Create skill database for better matching
75
+ self.skill_database = self._create_skill_database()
76
+
77
+ print("βœ… Standalone application initialized successfully!")
78
+
79
+ def _create_comprehensive_role_database(self):
80
+ """Create a comprehensive role database with detailed information."""
81
+ return {
82
+ # Analytics Category
83
+ "Business Analytics": {
84
+ "category": "Analytics",
85
+ "domain": "analytics",
86
+ "required_skills": ["SQL", "Excel", "Python", "Tableau", "Power BI", "Statistics", "Data Analysis", "Business Intelligence", "KPI", "Dashboard", "R", "Google Analytics"],
87
+ "description": "Analyze business data to identify trends, patterns, and insights that drive strategic decision-making and business growth",
88
+ "experience_level": "Mid-level",
89
+ "keywords": ["analytics", "business intelligence", "dashboard", "kpi", "metrics", "reporting", "data analysis", "insights", "visualization"],
90
+ "responsibilities": ["Create dashboards", "Analyze KPIs", "Generate reports", "Data visualization", "Business insights", "Trend analysis"],
91
+ "salary_range": "$70,000 - $120,000"
92
+ },
93
+ "Data Scientist": {
94
+ "category": "Analytics",
95
+ "domain": "data_science",
96
+ "required_skills": ["Python", "Machine Learning", "Statistics", "SQL", "Pandas", "Scikit-learn", "TensorFlow", "PyTorch", "Jupyter", "Data Mining", "Predictive Modeling"],
97
+ "description": "Build predictive models and analyze complex datasets to extract actionable insights",
98
+ "experience_level": "Senior-level",
99
+ "keywords": ["machine learning", "data science", "predictive modeling", "algorithms", "statistical analysis", "deep learning"],
100
+ "responsibilities": ["Model development", "Data analysis", "Algorithm design", "Statistical modeling", "Research"],
101
+ "salary_range": "$90,000 - $160,000"
102
+ },
103
+ "Data Visualisation": {
104
+ "category": "Analytics",
105
+ "domain": "analytics",
106
+ "required_skills": ["Tableau", "Power BI", "D3.js", "Python", "R", "Excel", "SQL", "Data Storytelling", "Dashboard Design", "Qlik", "Looker"],
107
+ "description": "Create compelling visual representations of data to communicate insights effectively to stakeholders",
108
+ "experience_level": "Mid-level",
109
+ "keywords": ["visualization", "dashboard", "charts", "graphs", "storytelling", "tableau", "power bi", "design", "infographics"],
110
+ "responsibilities": ["Design dashboards", "Create visualizations", "Data storytelling", "User experience design", "Interactive reports"],
111
+ "salary_range": "$65,000 - $110,000"
112
+ },
113
+
114
+ # Capital Markets Category
115
+ "Equity Research": {
116
+ "category": "Capital Markets",
117
+ "domain": "finance",
118
+ "required_skills": ["Financial Modeling", "Valuation", "Excel", "Bloomberg Terminal", "Equity Analysis", "DCF", "Comparable Analysis", "Industry Research", "Financial Statements"],
119
+ "description": "Analyze equity securities and provide investment recommendations based on fundamental and technical analysis",
120
+ "experience_level": "Mid-level",
121
+ "keywords": ["equity", "research", "valuation", "stocks", "investment", "analysis", "recommendations", "financial modeling"],
122
+ "responsibilities": ["Company analysis", "Financial modeling", "Investment recommendations", "Research reports", "Market analysis"],
123
+ "salary_range": "$80,000 - $150,000"
124
+ },
125
+ "Investment Banking": {
126
+ "category": "Capital Markets",
127
+ "domain": "finance",
128
+ "required_skills": ["Financial Modeling", "Valuation", "M&A", "Excel", "PowerPoint", "Bloomberg", "Capital Markets", "Due Diligence", "Pitch Books", "LBO Modeling"],
129
+ "description": "Provide financial advisory services for mergers, acquisitions, capital raising, and other corporate finance transactions",
130
+ "experience_level": "Senior-level",
131
+ "keywords": ["investment banking", "m&a", "ipo", "capital markets", "advisory", "transactions", "valuation", "financing"],
132
+ "responsibilities": ["M&A advisory", "Capital raising", "Financial modeling", "Pitch preparation", "Due diligence"],
133
+ "salary_range": "$100,000 - $200,000"
134
+ },
135
+ "Risk Management": {
136
+ "category": "Capital Markets",
137
+ "domain": "finance",
138
+ "required_skills": ["Risk Analysis", "VaR", "Monte Carlo", "Python", "R", "Excel", "Derivatives", "Credit Risk", "Market Risk", "Operational Risk"],
139
+ "description": "Identify, assess, and mitigate financial risks across trading, credit, and operational activities",
140
+ "experience_level": "Senior-level",
141
+ "keywords": ["risk", "var", "credit risk", "market risk", "compliance", "derivatives", "hedging", "portfolio"],
142
+ "responsibilities": ["Risk assessment", "Model development", "Regulatory reporting", "Portfolio monitoring", "Stress testing"],
143
+ "salary_range": "$90,000 - $160,000"
144
+ },
145
+
146
+ # Technology Category
147
+ "Software Engineer": {
148
+ "category": "Technology",
149
+ "domain": "technology",
150
+ "required_skills": ["Python", "JavaScript", "SQL", "Git", "APIs", "Web Development", "React", "Node.js", "Database Design", "Agile", "Problem Solving"],
151
+ "description": "Develop and maintain software applications using modern programming languages and frameworks",
152
+ "experience_level": "Mid-level",
153
+ "keywords": ["programming", "software development", "coding", "web development", "full stack", "backend", "frontend"],
154
+ "responsibilities": ["Code development", "Software design", "Testing", "Debugging", "Code reviews"],
155
+ "salary_range": "$75,000 - $140,000"
156
+ },
157
+ "Product Manager": {
158
+ "category": "Technology",
159
+ "domain": "product",
160
+ "required_skills": ["Product Strategy", "Roadmapping", "User Research", "Analytics", "Agile", "A/B Testing", "Stakeholder Management", "Market Research", "Feature Prioritization"],
161
+ "description": "Define product strategy, roadmap, and features based on market research and user needs",
162
+ "experience_level": "Senior-level",
163
+ "keywords": ["product management", "strategy", "roadmap", "user research", "agile", "features", "analytics"],
164
+ "responsibilities": ["Product strategy", "Roadmap planning", "Feature definition", "User research", "Stakeholder management"],
165
+ "salary_range": "$90,000 - $160,000"
166
+ },
167
+ "IT Business Analyst": {
168
+ "category": "Technology",
169
+ "domain": "technology",
170
+ "required_skills": ["Business Analysis", "Requirements Gathering", "Process Mapping", "SQL", "Agile", "JIRA", "Documentation", "Stakeholder Management", "Testing"],
171
+ "description": "Bridge business and technology teams by analyzing requirements and ensuring IT solutions meet business needs",
172
+ "experience_level": "Mid-level",
173
+ "keywords": ["business analyst", "requirements", "process analysis", "agile", "documentation", "stakeholder management"],
174
+ "responsibilities": ["Requirements analysis", "Process documentation", "Stakeholder coordination", "Solution design", "Testing support"],
175
+ "salary_range": "$70,000 - $110,000"
176
+ },
177
+
178
+ # Marketing Category
179
+ "Digital Marketing": {
180
+ "category": "Marketing",
181
+ "domain": "marketing",
182
+ "required_skills": ["SEO", "SEM", "Google Analytics", "Social Media", "Content Marketing", "PPC", "Email Marketing", "Facebook Ads", "Google Ads", "Marketing Automation"],
183
+ "description": "Develop and execute digital marketing campaigns across online channels to drive brand awareness and conversions",
184
+ "experience_level": "Mid-level",
185
+ "keywords": ["digital marketing", "seo", "sem", "social media", "google ads", "facebook", "content marketing", "ppc", "email"],
186
+ "responsibilities": ["Campaign management", "SEO optimization", "Social media strategy", "Content creation", "Analytics"],
187
+ "salary_range": "$55,000 - $95,000"
188
+ },
189
+ "Market Research": {
190
+ "category": "Marketing",
191
+ "domain": "marketing",
192
+ "required_skills": ["Survey Design", "Statistical Analysis", "SPSS", "R", "Excel", "Focus Groups", "Data Collection", "Consumer Insights", "Competitive Analysis"],
193
+ "description": "Conduct market research to understand consumer behavior, market trends, and competitive landscape",
194
+ "experience_level": "Mid-level",
195
+ "keywords": ["market research", "surveys", "consumer insights", "analysis", "trends", "competitive intelligence", "focus groups"],
196
+ "responsibilities": ["Research design", "Data collection", "Statistical analysis", "Insights generation", "Report presentation"],
197
+ "salary_range": "$60,000 - $100,000"
198
+ },
199
+ "Performance Marketing": {
200
+ "category": "Marketing",
201
+ "domain": "marketing",
202
+ "required_skills": ["Paid Advertising", "Google Ads", "Facebook Ads", "Analytics", "Conversion Tracking", "A/B Testing", "ROI Analysis", "Attribution Modeling"],
203
+ "description": "Drive measurable marketing results through data-driven paid advertising and performance optimization",
204
+ "experience_level": "Mid-level",
205
+ "keywords": ["performance marketing", "paid ads", "roi", "conversion", "optimization", "attribution", "programmatic"],
206
+ "responsibilities": ["Campaign optimization", "Performance analysis", "A/B testing", "Budget allocation", "ROI maximization"],
207
+ "salary_range": "$65,000 - $110,000"
208
+ },
209
+
210
+ # Sales Category
211
+ "B2B Sales": {
212
+ "category": "Sales",
213
+ "domain": "sales",
214
+ "required_skills": ["B2B Sales", "CRM", "Salesforce", "Lead Generation", "Negotiation", "Account Management", "Sales Process", "Pipeline Management", "Presentation"],
215
+ "description": "Drive business-to-business sales through relationship building, lead generation, and strategic account management",
216
+ "experience_level": "Mid-level",
217
+ "keywords": ["b2b sales", "enterprise sales", "account management", "lead generation", "crm", "pipeline", "negotiation"],
218
+ "responsibilities": ["Lead generation", "Account management", "Sales presentations", "Contract negotiation", "Relationship building"],
219
+ "salary_range": "$60,000 - $120,000"
220
+ },
221
+ "Technology Sales": {
222
+ "category": "Sales",
223
+ "domain": "sales",
224
+ "required_skills": ["Technology Products", "SaaS", "Software Sales", "Technical Knowledge", "Solution Selling", "CRM", "Salesforce", "Presentation", "ROI Analysis"],
225
+ "description": "Sell technology products and solutions by understanding customer technical requirements and demonstrating value",
226
+ "experience_level": "Mid-level",
227
+ "keywords": ["technology sales", "saas", "software", "solution selling", "technical sales", "enterprise software"],
228
+ "responsibilities": ["Technical sales", "Solution design", "Product demos", "ROI analysis", "Customer consultation"],
229
+ "salary_range": "$70,000 - $140,000"
230
+ },
231
+
232
+ # Human Resources Category
233
+ "HR Generalist": {
234
+ "category": "Human Resources",
235
+ "domain": "hr",
236
+ "required_skills": ["Recruitment", "Employee Relations", "HRIS", "Training", "Compliance", "Communication", "Performance Management", "Benefits Administration"],
237
+ "description": "Manage various HR functions including recruitment, employee relations, and policy implementation",
238
+ "experience_level": "Mid-level",
239
+ "keywords": ["human resources", "recruitment", "employee relations", "training", "compliance", "hr", "hiring", "benefits"],
240
+ "responsibilities": ["Recruitment", "Employee relations", "Training coordination", "Policy implementation", "Compliance"],
241
+ "salary_range": "$55,000 - $85,000"
242
+ },
243
+ "Talent Acquisition": {
244
+ "category": "Human Resources",
245
+ "domain": "hr",
246
+ "required_skills": ["Recruiting", "Sourcing", "Interviewing", "ATS", "LinkedIn Recruiter", "Boolean Search", "Employer Branding", "Candidate Experience"],
247
+ "description": "Source, attract, and hire top talent through strategic recruitment and talent acquisition strategies",
248
+ "experience_level": "Mid-level",
249
+ "keywords": ["recruiting", "talent acquisition", "sourcing", "hiring", "candidates", "interviews", "ats", "linkedin"],
250
+ "responsibilities": ["Candidate sourcing", "Interview coordination", "Talent pipeline management", "Employer branding", "Recruitment strategy"],
251
+ "salary_range": "$60,000 - $95,000"
252
+ },
253
+
254
+ # Operations Category
255
+ "Customer Success": {
256
+ "category": "Operations",
257
+ "domain": "operations",
258
+ "required_skills": ["Customer Relationship Management", "CRM", "Account Management", "Communication", "Problem Solving", "Analytics", "Retention Strategy", "Onboarding"],
259
+ "description": "Ensure customer satisfaction, retention, and growth through proactive relationship management and support",
260
+ "experience_level": "Mid-level",
261
+ "keywords": ["customer success", "retention", "account management", "onboarding", "satisfaction", "growth", "relationships"],
262
+ "responsibilities": ["Customer onboarding", "Relationship management", "Retention strategies", "Success metrics", "Account growth"],
263
+ "salary_range": "$60,000 - $100,000"
264
+ },
265
+ "Supply Chain Management": {
266
+ "category": "Operations",
267
+ "domain": "operations",
268
+ "required_skills": ["Supply Chain", "Logistics", "Procurement", "Inventory Management", "ERP", "SAP", "Vendor Management", "Forecasting", "Cost Optimization"],
269
+ "description": "Optimize supply chain operations including procurement, logistics, and inventory management",
270
+ "experience_level": "Senior-level",
271
+ "keywords": ["supply chain", "logistics", "procurement", "inventory", "vendor management", "optimization"],
272
+ "responsibilities": ["Supply planning", "Vendor management", "Inventory optimization", "Cost reduction", "Process improvement"],
273
+ "salary_range": "$75,000 - $130,000"
274
+ },
275
+
276
+ # Strategy Category
277
+ "Business Consulting": {
278
+ "category": "Strategy",
279
+ "domain": "consulting",
280
+ "required_skills": ["Strategy", "Business Analysis", "Problem Solving", "Presentation", "Excel", "PowerPoint", "Project Management", "Stakeholder Management"],
281
+ "description": "Provide strategic business advice and solutions to help organizations improve performance and achieve goals",
282
+ "experience_level": "Senior-level",
283
+ "keywords": ["consulting", "strategy", "business analysis", "problem solving", "advisory", "transformation"],
284
+ "responsibilities": ["Strategy development", "Business analysis", "Client advisory", "Project management", "Solution implementation"],
285
+ "salary_range": "$80,000 - $150,000"
286
+ },
287
+ "Corporate Strategy": {
288
+ "category": "Strategy",
289
+ "domain": "strategy",
290
+ "required_skills": ["Strategic Planning", "Business Analysis", "Financial Modeling", "M&A", "Market Analysis", "Competitive Intelligence", "Executive Presentation"],
291
+ "description": "Develop and execute corporate strategy including growth initiatives, M&A, and strategic planning",
292
+ "experience_level": "Senior-level",
293
+ "keywords": ["corporate strategy", "strategic planning", "m&a", "growth", "competitive analysis", "business development"],
294
+ "responsibilities": ["Strategy formulation", "M&A analysis", "Strategic planning", "Competitive analysis", "Executive reporting"],
295
+ "salary_range": "$90,000 - $160,000"
296
+ },
297
+
298
+ # Finance Category
299
+ "Financial Analyst": {
300
+ "category": "Finance",
301
+ "domain": "finance",
302
+ "required_skills": ["Excel", "Financial Modeling", "SQL", "Analytics", "Accounting", "Valuation", "Financial Reporting", "Budgeting", "Forecasting"],
303
+ "description": "Analyze financial data and create reports to support business decision-making",
304
+ "experience_level": "Mid-level",
305
+ "keywords": ["financial analysis", "modeling", "budgeting", "forecasting", "reporting", "excel", "accounting"],
306
+ "responsibilities": ["Financial analysis", "Model building", "Report generation", "Budget planning", "Variance analysis"],
307
+ "salary_range": "$65,000 - $110,000"
308
+ },
309
+ "Corporate Finance": {
310
+ "category": "Finance",
311
+ "domain": "finance",
312
+ "required_skills": ["Financial Modeling", "Valuation", "M&A", "Excel", "Capital Structure", "Treasury", "Financial Planning", "Investment Analysis"],
313
+ "description": "Manage corporate financial strategy, capital structure, and major financial transactions",
314
+ "experience_level": "Senior-level",
315
+ "keywords": ["corporate finance", "capital structure", "treasury", "m&a", "valuation", "strategy", "financing"],
316
+ "responsibilities": ["Capital planning", "M&A analysis", "Treasury management", "Financial strategy", "Investor relations"],
317
+ "salary_range": "$85,000 - $150,000"
318
+ }
319
+ }
320
+
321
+ def _create_skill_database(self):
322
+ """Create a comprehensive skill database with categories."""
323
+ return {
324
+ "programming": ["Python", "Java", "JavaScript", "C++", "C#", "R", "SQL", "HTML", "CSS", "PHP", "Ruby", "Go", "Rust", "Swift", "Kotlin", "Scala", "MATLAB"],
325
+ "data_science": ["Machine Learning", "Statistics", "Data Analysis", "Pandas", "NumPy", "Scikit-learn", "TensorFlow", "PyTorch", "Jupyter", "Data Mining", "Predictive Modeling", "Statistical Analysis"],
326
+ "web_development": ["React", "Angular", "Vue.js", "Node.js", "Django", "Flask", "Spring", "Express", "Bootstrap", "jQuery", "REST APIs", "GraphQL"],
327
+ "databases": ["MySQL", "PostgreSQL", "MongoDB", "Redis", "Oracle", "SQL Server", "Cassandra", "DynamoDB", "NoSQL", "Database Design"],
328
+ "cloud": ["AWS", "Azure", "Google Cloud", "Docker", "Kubernetes", "Terraform", "Jenkins", "CI/CD", "DevOps", "Microservices"],
329
+ "analytics": ["Tableau", "Power BI", "Google Analytics", "Excel", "SPSS", "SAS", "Looker", "Qlik", "D3.js", "Data Visualization", "Dashboard Design"],
330
+ "marketing": ["SEO", "SEM", "Google Ads", "Facebook Ads", "Content Marketing", "Email Marketing", "Social Media", "PPC", "Marketing Automation", "Conversion Optimization", "A/B Testing"],
331
+ "design": ["Figma", "Adobe Creative Suite", "Sketch", "InVision", "Photoshop", "Illustrator", "UI/UX Design", "Prototyping", "Wireframing", "User Research"],
332
+ "project_management": ["Agile", "Scrum", "Kanban", "JIRA", "Trello", "Asana", "Project Planning", "Risk Management", "PMP", "Waterfall", "Stakeholder Management"],
333
+ "finance": ["Financial Modeling", "Valuation", "Accounting", "Budgeting", "Forecasting", "Excel", "Bloomberg", "Financial Reporting", "GAAP", "IFRS", "DCF", "LBO"],
334
+ "capital_markets": ["Bloomberg Terminal", "Capital IQ", "Equity Research", "Fixed Income", "Derivatives", "Trading", "Portfolio Management", "Risk Management", "VaR", "Credit Analysis"],
335
+ "sales": ["CRM", "Salesforce", "Lead Generation", "Account Management", "Pipeline Management", "Negotiation", "B2B Sales", "B2C Sales", "Channel Sales", "Sales Process"],
336
+ "hr": ["Recruitment", "Talent Acquisition", "HRIS", "Employee Relations", "Performance Management", "Benefits Administration", "Training", "Compliance", "ATS", "LinkedIn Recruiter"],
337
+ "operations": ["Supply Chain", "Logistics", "Process Improvement", "Quality Management", "Vendor Management", "Inventory Management", "ERP", "SAP", "Lean Six Sigma", "ITIL"],
338
+ "consulting": ["Strategy", "Business Analysis", "Problem Solving", "Client Management", "Change Management", "Process Optimization", "Digital Transformation", "Management Consulting"],
339
+ "technology": ["Software Development", "System Architecture", "Technical Leadership", "Cybersecurity", "Network Administration", "IT Support", "Database Administration", "Solution Architecture"],
340
+ "research": ["Market Research", "Competitive Analysis", "Survey Design", "Focus Groups", "Statistical Analysis", "Research Methodology", "Data Collection", "Consumer Insights"],
341
+ "soft_skills": ["Leadership", "Communication", "Problem Solving", "Team Management", "Critical Thinking", "Negotiation", "Presentation", "Analytical Thinking", "Strategic Thinking", "Relationship Building"]
342
+ }
343
+
344
+ def _extract_skills_from_text(self, text: str) -> List[str]:
345
+ """Extract skills from text using keyword matching."""
346
+ text_lower = text.lower()
347
+ found_skills = []
348
+
349
+ # Check all skill categories
350
+ for category, skills in self.skill_database.items():
351
+ for skill in skills:
352
+ # Check for exact match or partial match
353
+ skill_lower = skill.lower()
354
+ if skill_lower in text_lower or any(word in text_lower for word in skill_lower.split()):
355
+ if skill not in found_skills:
356
+ found_skills.append(skill)
357
+
358
+ return found_skills
359
+
360
+ def _calculate_text_similarity(self, text1: str, text2: str) -> float:
361
+ """Calculate similarity between two texts using TF-IDF-like approach."""
362
+ # Simple tokenization
363
+ def tokenize(text):
364
+ return re.findall(r'\b\w+\b', text.lower())
365
+
366
+ tokens1 = tokenize(text1)
367
+ tokens2 = tokenize(text2)
368
+
369
+ # Calculate term frequencies
370
+ tf1 = Counter(tokens1)
371
+ tf2 = Counter(tokens2)
372
+
373
+ # Get all unique terms
374
+ all_terms = set(tokens1 + tokens2)
375
+
376
+ # Calculate cosine similarity
377
+ dot_product = sum(tf1[term] * tf2[term] for term in all_terms)
378
+ magnitude1 = math.sqrt(sum(tf1[term]**2 for term in all_terms))
379
+ magnitude2 = math.sqrt(sum(tf2[term]**2 for term in all_terms))
380
+
381
+ if magnitude1 == 0 or magnitude2 == 0:
382
+ return 0.0
383
+
384
+ return dot_product / (magnitude1 * magnitude2)
385
+
386
+ def _classify_domain(self, text: str) -> Tuple[str, float]:
387
+ """Simple domain classification based on keywords."""
388
+ domain_keywords = {
389
+ "analytics": ["analytics", "data analysis", "business intelligence", "dashboard", "visualization", "tableau", "power bi", "insights"],
390
+ "finance": ["financial", "accounting", "budget", "investment", "revenue", "profit", "banking", "capital markets", "equity", "valuation"],
391
+ "technology": ["programming", "software", "development", "coding", "web", "api", "database", "it", "technical", "system"],
392
+ "marketing": ["marketing", "seo", "social media", "advertising", "campaign", "brand", "digital marketing", "content"],
393
+ "hr": ["human resources", "recruitment", "hiring", "employee", "training", "hr", "talent acquisition", "benefits"],
394
+ "sales": ["sales", "revenue", "customer", "client", "negotiation", "crm", "b2b", "b2c", "channel"],
395
+ "operations": ["operations", "process", "supply chain", "logistics", "quality", "service", "customer success"],
396
+ "consulting": ["consulting", "strategy", "advisory", "business", "transformation", "research"],
397
+ "product": ["product", "roadmap", "user", "feature", "requirements", "product management"],
398
+ "data_science": ["machine learning", "data science", "predictive modeling", "algorithms", "statistical analysis"]
399
+ }
400
+
401
+ text_lower = text.lower()
402
+ domain_scores = {}
403
+
404
+ for domain, keywords in domain_keywords.items():
405
+ score = sum(1 for keyword in keywords if keyword in text_lower)
406
+ if score > 0:
407
+ domain_scores[domain] = score / len(keywords)
408
+
409
+ if domain_scores:
410
+ best_domain = max(domain_scores, key=domain_scores.get)
411
+ confidence = domain_scores[best_domain]
412
+ return best_domain, confidence
413
+
414
+ return "technology", 0.1 # Default
415
+
416
+ def enhanced_profile_analysis(self, profile_text: str) -> Tuple[str, str, str]:
417
+ """Enhanced profile analysis using standalone algorithms."""
418
+ if not profile_text.strip():
419
+ return "Please enter a profile text.", "", ""
420
+
421
+ try:
422
+ # 1. Basic profile parsing
423
+ parsed_profile = self.text_profile_parser.parse(profile_text)
424
+
425
+ # 2. Extract skills from profile
426
+ profile_skills = self._extract_skills_from_text(profile_text)
427
+
428
+ # 3. Domain classification
429
+ domain, domain_conf = self._classify_domain(profile_text)
430
+
431
+ # 4. Role matching
432
+ role_matches = self._find_role_matches(profile_text, profile_skills)
433
+
434
+ # 5. Get best role prediction
435
+ if role_matches:
436
+ predicted_role = role_matches[0]["role"]
437
+ predicted_category = role_matches[0]["category"]
438
+ predicted_domain = role_matches[0]["domain"]
439
+ confidence = role_matches[0]["similarity_score"]
440
+ else:
441
+ predicted_role = "Software Engineer"
442
+ predicted_category = "Technology"
443
+ predicted_domain = "technology"
444
+ confidence = 0.1
445
+
446
+ # 6. Skill gap analysis
447
+ gap_analysis = self._analyze_skill_gaps(profile_text, profile_skills, predicted_role)
448
+
449
+ # Prepare results
450
+ role_analysis = {
451
+ "predicted_role": predicted_role,
452
+ "predicted_category": predicted_category,
453
+ "predicted_domain": predicted_domain,
454
+ "confidence_scores": {"overall": confidence, "domain": domain_conf},
455
+ "top_role_matches": [
456
+ {
457
+ "role": match["role"],
458
+ "category": match["category"],
459
+ "similarity": f"{match['similarity_score']:.2%}",
460
+ "confidence": f"{match['confidence']:.2%}",
461
+ "matched_skills": match["matched_skills"],
462
+ "reasoning": match["reasoning"]
463
+ }
464
+ for match in role_matches[:5]
465
+ ],
466
+ "domain_analysis": {
467
+ "detected_domain": domain,
468
+ "confidence": f"{domain_conf:.2%}",
469
+ "profile_skills": profile_skills[:15] # Top 15 skills
470
+ },
471
+ "profile_sections": {
472
+ "education_count": len(parsed_profile.get("education", [])),
473
+ "experience_count": len(parsed_profile.get("experience", [])),
474
+ "projects_count": len(parsed_profile.get("projects", [])),
475
+ "achievements_count": len(parsed_profile.get("achievements", [])),
476
+ "certificates_count": len(parsed_profile.get("certificates", []))
477
+ },
478
+ "system_status": {
479
+ "mode": "Google Colab Standalone Mode",
480
+ "dependencies": "Zero external dependencies"
481
+ }
482
+ }
483
+
484
+ # Career recommendations HTML
485
+ career_recommendations = self._generate_career_recommendations_html(
486
+ predicted_role, predicted_category, predicted_domain, role_matches, gap_analysis
487
+ )
488
+
489
+ return (
490
+ json.dumps(role_analysis, indent=2),
491
+ json.dumps(gap_analysis, indent=2),
492
+ career_recommendations
493
+ )
494
+
495
+ except Exception as e:
496
+ error_msg = f"Error in profile analysis: {str(e)}"
497
+ return error_msg, "", ""
498
+
499
+ def _find_role_matches(self, profile_text: str, profile_skills: List[str]) -> List[Dict]:
500
+ """Find role matches using multiple scoring methods."""
501
+ matches = []
502
+
503
+ for role, data in self.role_database.items():
504
+ # 1. Skill-based scoring
505
+ matched_skills = []
506
+ for skill in data["required_skills"]:
507
+ if skill in profile_skills:
508
+ matched_skills.append(skill)
509
+
510
+ skill_score = len(matched_skills) / len(data["required_skills"]) if data["required_skills"] else 0
511
+
512
+ # 2. Keyword-based scoring
513
+ keyword_score = 0
514
+ for keyword in data["keywords"]:
515
+ if keyword.lower() in profile_text.lower():
516
+ keyword_score += 1
517
+ keyword_score = keyword_score / len(data["keywords"]) if data["keywords"] else 0
518
+
519
+ # 3. Text similarity scoring
520
+ role_text = f"{data['description']} {' '.join(data['required_skills'])} {' '.join(data['keywords'])}"
521
+ text_similarity = self._calculate_text_similarity(profile_text, role_text)
522
+
523
+ # 4. Combined scoring
524
+ combined_score = (skill_score * 0.4) + (keyword_score * 0.3) + (text_similarity * 0.3)
525
+
526
+ # 5. Confidence calculation
527
+ confidence = min(combined_score + (len(matched_skills) * 0.05), 1.0)
528
+
529
+ # 6. Reasoning
530
+ reasoning = f"Skills: {len(matched_skills)}/{len(data['required_skills'])}, Keywords: {int(keyword_score * len(data['keywords']))}/{len(data['keywords'])}, Text similarity: {text_similarity:.2%}"
531
+
532
+ matches.append({
533
+ "role": role,
534
+ "category": data["category"],
535
+ "domain": data["domain"],
536
+ "similarity_score": combined_score,
537
+ "confidence": confidence,
538
+ "matched_skills": matched_skills,
539
+ "reasoning": reasoning,
540
+ "salary_range": data.get("salary_range", "Not specified")
541
+ })
542
+
543
+ # Sort by combined score
544
+ matches.sort(key=lambda x: x["similarity_score"], reverse=True)
545
+ return matches
546
+
547
+ def _analyze_skill_gaps(self, profile_text: str, profile_skills: List[str], target_role: str) -> Dict:
548
+ """Analyze skill gaps for the target role."""
549
+ if target_role not in self.role_database:
550
+ return {"error": f"Role '{target_role}' not found"}
551
+
552
+ role_data = self.role_database[target_role]
553
+ required_skills = set(role_data["required_skills"])
554
+ current_skills = set(profile_skills)
555
+
556
+ matching_skills = list(required_skills & current_skills)
557
+ missing_skills = list(required_skills - current_skills)
558
+
559
+ # Generate recommendations
560
+ recommendations = []
561
+ skill_learning_map = {
562
+ "python": "Complete Python programming courses on Coursera or edX",
563
+ "sql": "Practice SQL queries on HackerRank or LeetCode",
564
+ "tableau": "Get Tableau certification through official Tableau training",
565
+ "power bi": "Complete Microsoft Power BI certification path",
566
+ "machine learning": "Take Andrew Ng's Machine Learning course on Coursera",
567
+ "aws": "Pursue AWS certification starting with Cloud Practitioner",
568
+ "javascript": "Complete JavaScript fundamentals on freeCodeCamp",
569
+ "react": "Build projects using React through official React tutorial",
570
+ "excel": "Complete advanced Excel courses focusing on data analysis",
571
+ "agile": "Consider Scrum Master or Product Owner certification",
572
+ "google analytics": "Complete Google Analytics certification",
573
+ "seo": "Take SEO courses on Moz Academy or SEMrush",
574
+ "financial modeling": "Complete financial modeling courses on Wall Street Prep",
575
+ "bloomberg terminal": "Get Bloomberg Market Concepts (BMC) certification",
576
+ "salesforce": "Pursue Salesforce Administrator certification",
577
+ "crm": "Learn CRM best practices through HubSpot Academy"
578
+ }
579
+
580
+ for skill in missing_skills[:8]: # Top 8 missing skills
581
+ skill_lower = skill.lower()
582
+ recommendation = skill_learning_map.get(skill_lower, f"Seek online courses or tutorials for {skill}")
583
+
584
+ # Determine priority
585
+ if skill_lower in ["python", "sql", "excel", "javascript"]:
586
+ priority = "High"
587
+ elif skill_lower in ["tableau", "power bi", "aws", "react"]:
588
+ priority = "Medium"
589
+ else:
590
+ priority = "Low"
591
+
592
+ recommendations.append({
593
+ "skill": skill,
594
+ "recommendation": recommendation,
595
+ "priority": priority,
596
+ "estimated_time": "2-4 weeks" if priority == "High" else "1-2 weeks"
597
+ })
598
+
599
+ # Calculate match percentage
600
+ match_percentage = len(matching_skills) / len(required_skills) if required_skills else 0
601
+
602
+ return {
603
+ "target_role": target_role,
604
+ "current_match": f"{match_percentage:.1%}",
605
+ "matching_skills": matching_skills,
606
+ "skill_gaps": missing_skills,
607
+ "recommendations": recommendations,
608
+ "role_info": {
609
+ "description": role_data["description"],
610
+ "experience_level": role_data["experience_level"],
611
+ "salary_range": role_data.get("salary_range", "Not specified"),
612
+ "key_responsibilities": role_data.get("responsibilities", [])
613
+ }
614
+ }
615
+
616
+ def _generate_career_recommendations_html(self, predicted_role: str, predicted_category: str,
617
+ predicted_domain: str, role_matches: List[Dict],
618
+ gap_analysis: Dict) -> str:
619
+ """Generate comprehensive HTML for career recommendations."""
620
+
621
+ best_match = role_matches[0] if role_matches else None
622
+
623
+ html = f"""
624
+ <div style="font-family: Arial, sans-serif; max-width: 900px; color: white;">
625
+ <h2 style="color: white; border-bottom: 2px solid #D1C4E9; padding-bottom: 10px;">
626
+ 🎯 Career Recommendations & Analysis
627
+ </h2>
628
+
629
+ <div style="background: #7E57C2; padding: 20px; border-radius: 10px; margin: 20px 0;">
630
+ <h3 style="color: white; margin-top: 0;">
631
+ πŸ† Best Role Match: {predicted_role}
632
+ </h3>
633
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; color: #F3E5F5;">
634
+ <div>
635
+ <p><strong>Category:</strong> {predicted_category}</p>
636
+ <p><strong>Domain:</strong> {predicted_domain}</p>
637
+ </div>
638
+ <div>
639
+ <p><strong>Match Score:</strong> {best_match['similarity_score']:.1%}</p>
640
+ <p><strong>Salary Range:</strong> {best_match.get('salary_range', 'Not specified')}</p>
641
+ </div>
642
+ </div>
643
+ </div>
644
+
645
+ <div style="background: #5E35B1; padding: 20px; border-radius: 10px; margin: 20px 0;">
646
+ <h3 style="color: white; margin-top: 0;">πŸ“ˆ Top Alternative Roles</h3>
647
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
648
+ """
649
+
650
+ for i, match in enumerate(role_matches[1:5], 1): # Top 4 alternatives
651
+ html += f"""
652
+ <div style="background: #7E57C2; color: white; padding: 10px; border-radius: 5px; border-left: 3px solid #D1C4E9;">
653
+ <strong>{match['role']}</strong><br>
654
+ <small style="color: #F3E5F5;">Category: {match['category']} | Score: {match['similarity_score']:.1%}</small>
655
+ </div>
656
+ """
657
+
658
+ html += """
659
+ </div>
660
+ </div>
661
+ """
662
+
663
+ # Skill recommendations
664
+ if gap_analysis.get("recommendations"):
665
+ html += """
666
+ <div style="background: #5E35B1; padding: 20px; border-radius: 10px; margin: 20px 0;">
667
+ <h3 style="color: white; margin-top: 0;">πŸŽ“ Skill Development Roadmap</h3>
668
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
669
+ """
670
+
671
+ high_priority = [rec for rec in gap_analysis["recommendations"] if rec["priority"] == "High"]
672
+ medium_priority = [rec for rec in gap_analysis["recommendations"] if rec["priority"] == "Medium"]
673
+
674
+ html += """
675
+ <div>
676
+ <h4 style="color: white; margin-top: 0;">πŸ”₯ High Priority Skills</h4>
677
+ """
678
+
679
+ for rec in high_priority[:3]:
680
+ html += f"""
681
+ <div style="margin: 10px 0; padding: 10px; background: #7E57C2; color: white; border-radius: 5px; border-left: 3px solid #D1C4E9;">
682
+ <strong>{rec['skill']}</strong>
683
+ <br><small style="color: #F3E5F5;">⏱️ {rec.get('estimated_time', '2-4 weeks')}</small>
684
+ <br><small style="color: #F3E5F5;">πŸ’‘ {rec['recommendation']}</small>
685
+ </div>
686
+ """
687
+
688
+ html += """
689
+ </div>
690
+ <div>
691
+ <h4 style="color: white; margin-top: 0;">⭐ Medium Priority Skills</h4>
692
+ """
693
+
694
+ for rec in medium_priority[:3]:
695
+ html += f"""
696
+ <div style="margin: 10px 0; padding: 10px; background: #7E57C2; color: white; border-radius: 5px; border-left: 3px solid #D1C4E9;">
697
+ <strong>{rec['skill']}</strong>
698
+ <br><small style="color: #F3E5F5;">⏱️ {rec.get('estimated_time', '1-2 weeks')}</small>
699
+ <br><small style="color: #F3E5F5;">πŸ’‘ {rec['recommendation']}</small>
700
+ </div>
701
+ """
702
+
703
+ html += """
704
+ </div>
705
+ </div>
706
+ </div>
707
+ """
708
+
709
+ # Career path suggestions
710
+ html += f"""
711
+ <div style="background: #512DA8; padding: 20px; border-radius: 10px; margin: 20px 0;">
712
+ <h3 style="color: white; margin-top: 0;">πŸš€ Career Development Path</h3>
713
+ <div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px;">
714
+ <div style="background: #673AB7; color: white; padding: 15px; border-radius: 8px;">
715
+ <h4 style="color: white; margin-top: 0;">πŸ“š Immediate (1-3 months)</h4>
716
+ <ul style="margin: 0; padding-left: 20px; font-size: 14px; color: #F3E5F5;">
717
+ <li>Focus on high-priority skills</li>
718
+ <li>Complete online certifications</li>
719
+ <li>Build portfolio projects</li>
720
+ <li>Network in {predicted_domain} domain</li>
721
+ </ul>
722
+ </div>
723
+ <div style="background: #673AB7; color: white; padding: 15px; border-radius: 8px;">
724
+ <h4 style="color: white; margin-top: 0;">🎯 Short-term (3-12 months)</h4>
725
+ <ul style="margin: 0; padding-left: 20px; font-size: 14px; color: #F3E5F5;">
726
+ <li>Apply for {predicted_role} positions</li>
727
+ <li>Gain hands-on experience</li>
728
+ <li>Develop medium-priority skills</li>
729
+ <li>Seek mentorship opportunities</li>
730
+ </ul>
731
+ </div>
732
+ <div style="background: #673AB7; color: white; padding: 15px; border-radius: 8px;">
733
+ <h4 style="color: white; margin-top: 0;">🌟 Long-term (1-2 years)</h4>
734
+ <ul style="margin: 0; padding-left: 20px; font-size: 14px; color: #F3E5F5;">
735
+ <li>Target senior roles in {predicted_category}</li>
736
+ <li>Develop leadership skills</li>
737
+ <li>Consider specialization</li>
738
+ <li>Explore management tracks</li>
739
+ </ul>
740
+ </div>
741
+ </div>
742
+ </div>
743
+ </div>
744
+ """
745
+
746
+ return html
747
+
748
+ def compare_profile_with_jd(self, profile_text: str, job_description: str) -> str:
749
+ """Compare a profile with a job description and provide detailed analysis."""
750
+ if not profile_text.strip() or not job_description.strip():
751
+ return "Please provide both profile and job description for comparison."
752
+
753
+ try:
754
+ # Analyze the profile
755
+ profile_analysis = self.enhanced_profile_analysis(profile_text)
756
+ role_analysis = json.loads(profile_analysis[0])
757
+
758
+ # Extract skills from profile and JD
759
+ profile_skills = set(role_analysis["domain_analysis"]["profile_skills"])
760
+ jd_skills = self._extract_skills_from_text(job_description)
761
+ jd_skills_set = set(jd_skills)
762
+
763
+ # Calculate text similarity between profile and JD
764
+ text_similarity = self._calculate_text_similarity(profile_text, job_description)
765
+
766
+ # Find matching and missing skills
767
+ matching_skills = list(profile_skills & jd_skills_set)
768
+ missing_skills = list(jd_skills_set - profile_skills)
769
+ extra_skills = list(profile_skills - jd_skills_set)
770
+
771
+ # Calculate overall match score
772
+ skill_match_score = len(matching_skills) / len(jd_skills_set) if jd_skills_set else 0
773
+ overall_score = (skill_match_score * 0.6) + (text_similarity * 0.4)
774
+
775
+ # Determine match level
776
+ if overall_score >= 0.8:
777
+ match_level = "Excellent Match"
778
+ elif overall_score >= 0.6:
779
+ match_level = "Good Match"
780
+ elif overall_score >= 0.4:
781
+ match_level = "Fair Match"
782
+ else:
783
+ match_level = "Poor Match"
784
+
785
+ # Extract key requirements from JD
786
+ jd_domain, jd_domain_conf = self._classify_domain(job_description)
787
+
788
+ comparison = {
789
+ "overall_match_score": f"{overall_score:.1%}",
790
+ "match_level": match_level,
791
+ "profile_analysis": {
792
+ "predicted_role": role_analysis["predicted_role"],
793
+ "category": role_analysis["predicted_category"],
794
+ "domain": role_analysis["predicted_domain"],
795
+ "confidence": role_analysis["confidence_scores"]["overall"],
796
+ "total_skills": len(profile_skills)
797
+ },
798
+ "job_description_analysis": {
799
+ "detected_domain": jd_domain,
800
+ "domain_confidence": f"{jd_domain_conf:.1%}",
801
+ "required_skills": jd_skills,
802
+ "total_required_skills": len(jd_skills_set)
803
+ },
804
+ "skill_analysis": {
805
+ "matching_skills": matching_skills,
806
+ "matching_skills_count": len(matching_skills),
807
+ "missing_skills": missing_skills[:10], # Top 10 missing skills
808
+ "missing_skills_count": len(missing_skills),
809
+ "extra_skills": extra_skills[:5], # Top 5 extra skills
810
+ "skill_match_percentage": f"{skill_match_score:.1%}"
811
+ },
812
+ "compatibility_scores": {
813
+ "skill_compatibility": f"{skill_match_score:.1%}",
814
+ "text_similarity": f"{text_similarity:.1%}",
815
+ "overall_score": f"{overall_score:.1%}"
816
+ },
817
+ "recommendations": {
818
+ "should_apply": overall_score >= 0.5,
819
+ "key_improvements": missing_skills[:5],
820
+ "strengths": matching_skills[:5],
821
+ "interview_readiness": "High" if overall_score >= 0.7 else "Medium" if overall_score >= 0.5 else "Low"
822
+ }
823
+ }
824
+
825
+ return json.dumps(comparison, indent=2)
826
+
827
+ except Exception as e:
828
+ return f"Error in profile vs JD comparison: {str(e)}"
829
+
830
+ def compare_profile_with_jd_detailed(self, profile_text: str, job_description: str) -> tuple:
831
+ """Compare profile with JD and return both JSON and detailed HTML analysis."""
832
+ if not profile_text.strip() or not job_description.strip():
833
+ return "Please provide both profile and job description for comparison.", ""
834
+
835
+ try:
836
+ # Get the basic comparison
837
+ comparison_json = self.compare_profile_with_jd(profile_text, job_description)
838
+ comparison_data = json.loads(comparison_json)
839
+
840
+ # Generate detailed HTML analysis
841
+ detailed_html = self._generate_jd_comparison_html(comparison_data)
842
+
843
+ return comparison_json, detailed_html
844
+
845
+ except Exception as e:
846
+ error_msg = f"Error in detailed profile vs JD comparison: {str(e)}"
847
+ return error_msg, ""
848
+
849
+ def _generate_jd_comparison_html(self, comparison_data: dict) -> str:
850
+ """Generate detailed HTML for profile vs JD comparison."""
851
+ overall_score = float(comparison_data["overall_match_score"].replace('%', '')) / 100
852
+ match_level = comparison_data["match_level"]
853
+
854
+ # Determine color based on match level - NEW PURPLE THEME
855
+ if overall_score >= 0.8:
856
+ score_color = "#673AB7" # Bright Purple for Excellent
857
+ elif overall_score >= 0.6:
858
+ score_color = "#7E57C2" # Medium Purple for Good
859
+ elif overall_score >= 0.4:
860
+ score_color = "#9575CD" # Lighter Purple for Fair
861
+ else:
862
+ score_color = "#5E35B1" # Darker Purple for Poor
863
+
864
+ html = f"""
865
+ <div style="font-family: Arial, sans-serif; max-width: 900px; color: white;">
866
+ <h2 style="color: white; border-bottom: 2px solid #D1C4E9; padding-bottom: 10px;">
867
+ πŸ“Š Profile vs Job Description Analysis
868
+ </h2>
869
+
870
+ <div style="background: {score_color}; padding: 20px; border-radius: 10px; margin: 20px 0; text-align: center;">
871
+ <h3 style="margin: 0; font-size: 24px; color: white;">
872
+ {match_level}: {comparison_data['overall_match_score']}
873
+ </h3>
874
+ <p style="margin: 10px 0 0 0; font-size: 16px; color: #F3E5F5;">
875
+ Interview Readiness: {comparison_data['recommendations']['interview_readiness']}
876
+ </p>
877
+ </div>
878
+
879
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0;">
880
+ <div style="background: #5E35B1; padding: 20px; border-radius: 10px;">
881
+ <h3 style="color: white; margin-top: 0;">πŸ‘€ Profile Analysis</h3>
882
+ <p><strong>Predicted Role:</strong> {comparison_data['profile_analysis']['predicted_role']}</p>
883
+ <p><strong>Category:</strong> {comparison_data['profile_analysis']['category']}</p>
884
+ <p><strong>Domain:</strong> {comparison_data['profile_analysis']['domain']}</p>
885
+ <p><strong>Total Skills:</strong> {comparison_data['profile_analysis']['total_skills']}</p>
886
+ </div>
887
+
888
+ <div style="background: #5E35B1; padding: 20px; border-radius: 10px;">
889
+ <h3 style="color: white; margin-top: 0;">πŸ“„ Job Requirements</h3>
890
+ <p><strong>Detected Domain:</strong> {comparison_data['job_description_analysis']['detected_domain']}</p>
891
+ <p><strong>Domain Confidence:</strong> {comparison_data['job_description_analysis']['domain_confidence']}</p>
892
+ <p><strong>Required Skills:</strong> {comparison_data['job_description_analysis']['total_required_skills']}</p>
893
+ </div>
894
+ </div>
895
+
896
+ <div style="background: #673AB7; padding: 20px; border-radius: 10px; margin: 20px 0;">
897
+ <h3 style="color: white; margin-top: 0;">βœ… Matching Skills ({comparison_data['skill_analysis']['matching_skills_count']} skills)</h3>
898
+ <div style="display: flex; flex-wrap: wrap; gap: 8px;">
899
+ """
900
+
901
+ for skill in comparison_data['skill_analysis']['matching_skills']:
902
+ html += f'<span style="background: #512DA8; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">{skill}</span>'
903
+
904
+ html += """
905
+ </div>
906
+ </div>
907
+ """
908
+
909
+ if comparison_data['skill_analysis']['missing_skills']:
910
+ html += f"""
911
+ <div style="background: #7E57C2; padding: 20px; border-radius: 10px; margin: 20px 0;">
912
+ <h3 style="color: white; margin-top: 0;">❌ Missing Skills ({comparison_data['skill_analysis']['missing_skills_count']} skills)</h3>
913
+ <div style="display: flex; flex-wrap: wrap; gap: 8px;">
914
+ """
915
+
916
+ for skill in comparison_data['skill_analysis']['missing_skills']:
917
+ html += f'<span style="background: #9575CD; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px;">{skill}</span>'
918
+
919
+ html += """
920
+ </div>
921
+ </div>
922
+ """
923
+
924
+ html += f"""
925
+ <div style="background: #512DA8; padding: 20px; border-radius: 10px; margin: 20px 0;">
926
+ <h3 style="color: white; margin-top: 0;">πŸ“ˆ Compatibility Scores</h3>
927
+ <div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; text-align: center;">
928
+ <div>
929
+ <h4 style="margin: 0;">Skill Match</h4>
930
+ <p style="font-size: 18px; font-weight: bold; margin: 5px 0;">{comparison_data['compatibility_scores']['skill_compatibility']}</p>
931
+ </div>
932
+ <div>
933
+ <h4 style="margin: 0;">Text Similarity</h4>
934
+ <p style="font-size: 18px; font-weight: bold; margin: 5px 0;">{comparison_data['compatibility_scores']['text_similarity']}</p>
935
+ </div>
936
+ <div>
937
+ <h4 style="margin: 0;">Overall Score</h4>
938
+ <p style="font-size: 18px; font-weight: bold; margin: 5px 0;">{comparison_data['compatibility_scores']['overall_score']}</p>
939
+ </div>
940
+ </div>
941
+ </div>
942
+
943
+ <div style="background: #4527A0; padding: 20px; border-radius: 10px; margin: 20px 0;">
944
+ <h3 style="color: white; margin-top: 0;">πŸ’‘ Recommendations</h3>
945
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; color: #F3E5F5;">
946
+ <div>
947
+ <h4>Should Apply?</h4>
948
+ <p style="font-weight: bold; color: white;">
949
+ {"βœ… Yes, good fit!" if comparison_data['recommendations']['should_apply'] else "❌ Consider improving skills first"}
950
+ </p>
951
+
952
+ <h4>Key Strengths:</h4>
953
+ <ul>
954
+ """
955
+
956
+ for strength in comparison_data['recommendations']['strengths']:
957
+ html += f"<li>{strength}</li>"
958
+
959
+ html += f"""
960
+ </ul>
961
+ </div>
962
+ <div>
963
+ <h4>Priority Improvements:</h4>
964
+ <ul>
965
+ """
966
+
967
+ for improvement in comparison_data['recommendations']['key_improvements']:
968
+ html += f"<li>{improvement}</li>"
969
+
970
+ html += """
971
+ </ul>
972
+ </div>
973
+ </div>
974
+ </div>
975
+ </div>
976
+ """
977
+
978
+ return html
979
+
980
+
981
+ def create_colab_interface():
982
+ """Create Gradio interface optimized for Google Colab."""
983
+ app = StandaloneResumeMatcherApp()
984
+
985
+ with gr.Blocks(title="Resume Matcher for Google Colab", theme=gr.themes.Soft()) as interface:
986
+ gr.Markdown("# πŸš€ Resume Matcher - Google Colab Edition")
987
+ gr.Markdown("""
988
+ **βœ… Zero Dependencies | ⚑ Instant Results | 🎯 Advanced AI Analytics**
989
+
990
+ **Perfect for Google Colab - Just paste and run!**
991
+
992
+ **Key Features:**
993
+ - 🎯 **Smart Role Matching**: AI-powered role classification across 20+ roles
994
+ - πŸ“Š **Skill Gap Analysis**: Identifies missing skills with learning roadmaps
995
+ - πŸ“‹ **Profile vs Job Matching**: Detailed compatibility scoring
996
+ - πŸ’° **Salary Insights**: Market salary ranges for different roles
997
+ - πŸŽ“ **Learning Recommendations**: Personalized skill development plans
998
+ - πŸš€ **Career Roadmaps**: Short-term and long-term career guidance
999
+ """)
1000
+
1001
+ with gr.Tabs():
1002
+ # Tab 1: Profile Analysis
1003
+ with gr.TabItem("🎯 Profile Analysis"):
1004
+ with gr.Row():
1005
+ with gr.Column(scale=1):
1006
+ gr.Markdown("## πŸ“ Candidate Profile Input")
1007
+ profile_input = gr.Textbox(
1008
+ label="Paste Candidate Profile",
1009
+ placeholder="""Example format:
1010
+
1011
+ Education:
1012
+ Master's in Computer Science - Stanford University - 3.8 GPA
1013
+
1014
+ Experience:
1015
+ Google - Software Engineer - 2020-2023 - Developed web applications using React and Python
1016
+ Microsoft - Intern - 2019 - Built machine learning models for data analysis
1017
+
1018
+ Skills:
1019
+ Python, JavaScript, React, SQL, Machine Learning, AWS, Git, Agile, Problem Solving
1020
+
1021
+ Projects:
1022
+ E-commerce Platform - Built full-stack web application with React frontend and Django backend
1023
+ Data Analysis Tool - Created Python-based tool for analyzing customer behavior data
1024
+
1025
+ Achievements:
1026
+ AWS Certified Developer, Published research paper on ML algorithms, Led team of 5 developers""",
1027
+ lines=20,
1028
+ max_lines=30
1029
+ )
1030
+
1031
+ analyze_btn = gr.Button("πŸ” Analyze Profile", variant="primary", size="lg")
1032
+
1033
+ with gr.Column(scale=1):
1034
+ gr.Markdown("## πŸ“Š Analysis Results")
1035
+
1036
+ with gr.Tabs():
1037
+ with gr.TabItem("🎯 Role Classification"):
1038
+ role_analysis_output = gr.JSON(label="Detailed Role Analysis")
1039
+
1040
+ with gr.TabItem("πŸ“ˆ Skill Gap Analysis"):
1041
+ skill_gap_output = gr.JSON(label="Skill Gap & Recommendations")
1042
+
1043
+ with gr.TabItem("πŸš€ Career Roadmap"):
1044
+ career_recommendations_output = gr.HTML(label="Career Development Plan")
1045
+
1046
+ analyze_btn.click(
1047
+ fn=app.enhanced_profile_analysis,
1048
+ inputs=[profile_input],
1049
+ outputs=[role_analysis_output, skill_gap_output, career_recommendations_output]
1050
+ )
1051
+
1052
+ # Tab 2: Profile vs Job Description
1053
+ with gr.TabItem("πŸ“‹ Profile vs Job Description"):
1054
+ gr.Markdown("## 🎯 Compare Profile Against Job Description")
1055
+
1056
+ with gr.Row():
1057
+ with gr.Column():
1058
+ gr.Markdown("### πŸ‘€ Candidate Profile")
1059
+ profile_jd_input = gr.Textbox(
1060
+ label="Candidate Profile",
1061
+ lines=12,
1062
+ placeholder="Paste candidate profile here..."
1063
+ )
1064
+
1065
+ with gr.Column():
1066
+ gr.Markdown("### πŸ“„ Job Description")
1067
+ jd_input = gr.Textbox(
1068
+ label="Job Description",
1069
+ lines=12,
1070
+ placeholder="""Paste job description here...
1071
+
1072
+ Example:
1073
+ We are looking for a Software Engineer to join our team.
1074
+
1075
+ Requirements:
1076
+ - 3+ years of experience in Python or Java
1077
+ - Experience with web frameworks (Django, Flask, Spring)
1078
+ - Knowledge of databases (SQL, NoSQL)
1079
+ - Experience with cloud platforms (AWS, GCP, Azure)
1080
+ - Strong problem-solving skills
1081
+ - Bachelor's degree in Computer Science or related field
1082
+
1083
+ Responsibilities:
1084
+ - Develop and maintain web applications
1085
+ - Collaborate with cross-functional teams
1086
+ - Write clean, maintainable code
1087
+ - Participate in code reviews
1088
+ - Debug and resolve technical issues"""
1089
+ )
1090
+
1091
+ compare_jd_btn = gr.Button("πŸ” Analyze Match Score", variant="primary", size="lg")
1092
+
1093
+ with gr.Tabs():
1094
+ with gr.TabItem("πŸ“Š Match Score & Analysis"):
1095
+ jd_comparison_output = gr.JSON(label="Profile vs JD Analysis")
1096
+
1097
+ with gr.TabItem("πŸ“ˆ Detailed Breakdown"):
1098
+ jd_detailed_output = gr.HTML(label="Detailed Match Analysis")
1099
+
1100
+ compare_jd_btn.click(
1101
+ fn=app.compare_profile_with_jd_detailed,
1102
+ inputs=[profile_jd_input, jd_input],
1103
+ outputs=[jd_comparison_output, jd_detailed_output]
1104
+ )
1105
+
1106
+ with gr.Accordion("ℹ️ How to Use & Features", open=False):
1107
+ gr.Markdown("""
1108
+ ### πŸš€ Quick Start Guide:
1109
+
1110
+ 1. **Profile Analysis**: Paste a candidate's resume/profile in the first tab to get:
1111
+ - AI-powered role predictions with confidence scores
1112
+ - Skill gap analysis with priority levels
1113
+ - Personalized learning recommendations
1114
+ - Career development roadmap
1115
+
1116
+ 2. **Profile vs Job Matching**: Compare a profile against a job description to get:
1117
+ - Overall compatibility score
1118
+ - Detailed skill matching analysis
1119
+ - Interview readiness assessment
1120
+ - Specific improvement recommendations
1121
+
1122
+ ### 🎯 What Makes This Special:
1123
+
1124
+ - **Zero Setup**: No installations, dependencies, or API keys needed
1125
+ - **Instant Results**: Fast processing with immediate feedback
1126
+ - **Comprehensive Analysis**: 20+ role types across 8 major categories
1127
+ - **Smart Algorithms**: Multi-factor scoring (skills + keywords + text similarity)
1128
+ - **Actionable Insights**: Specific learning paths and career guidance
1129
+
1130
+ ### πŸ“Š Supported Roles:
1131
+
1132
+ **Analytics**: Business Analytics, Data Scientist, Data Visualization
1133
+ **Technology**: Software Engineer, Product Manager, IT Business Analyst
1134
+ **Finance**: Financial Analyst, Corporate Finance, Equity Research, Investment Banking
1135
+ **Marketing**: Digital Marketing, Market Research, Performance Marketing
1136
+ **Sales**: B2B Sales, Technology Sales
1137
+ **HR**: HR Generalist, Talent Acquisition
1138
+ **Operations**: Customer Success, Supply Chain Management
1139
+ **Strategy**: Business Consulting, Corporate Strategy
1140
+
1141
+ ### πŸ’‘ Pro Tips:
1142
+ - Include specific technologies, tools, and years of experience
1143
+ - Mention quantifiable achievements (e.g., "Improved efficiency by 30%")
1144
+ - Add both technical and soft skills
1145
+ - Include relevant certifications and education details
1146
+ """)
1147
+
1148
+ return interface
1149
+
1150
+
1151
+ # Main execution
1152
+ if __name__ == "__main__":
1153
+ print("πŸš€ Starting Resume Matcher for Google Colab...")
1154
+ print("βœ… No external dependencies required!")
1155
+ print("πŸ“Š Loading comprehensive role database...")
1156
+
1157
+ interface = create_colab_interface()
1158
+
1159
+ print("🎯 Ready to analyze resumes and match profiles!")
1160
+ print("πŸ’‘ Features: Role Classification | Skill Gap Analysis | Job Matching | Career Recommendations")
1161
+
1162
+ # Launch with Colab-optimized settings
1163
+ interface.launch(
1164
+ share=True, # Creates public link for sharing
1165
+ debug=True, # Shows detailed error messages
1166
+ show_error=True, # Display errors in interface
1167
+ quiet=False # Show startup logs
1168
+ )
1169
+