Roger Surf commited on
Commit
782c177
·
1 Parent(s): 1aa53e7

feat: add HRHUB notebook with corrected paths and data structure

Browse files
.gitignore CHANGED
@@ -4,4 +4,5 @@ __pycache__/
4
  *.pyo
5
  .DS_Store
6
  *.log
7
- .streamlit/
 
 
4
  *.pyo
5
  .DS_Store
6
  *.log
7
+ .streamlit/
8
+ *.csv
README.md.backup ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: HRHUB
3
+ emoji: 💼
4
+ colorFrom: green
5
+ colorTo: blue
6
+ sdk: streamlit
7
+ sdk_version: "1.34.0"
8
+ app_file: app.py
9
+ pinned: true
10
+ ---
11
+
12
+ # 🏢 HRHUB - HR Matching System
13
+
14
+ **Bilateral Matching Engine for Candidates & Companies**
15
+
16
+ A professional HR matching system using NLP embeddings and cosine similarity to connect job candidates with relevant companies based on skills, experience, and requirements.
17
+
18
+ ---
19
+
20
+
21
+
22
+ HRHUB solves a fundamental inefficiency in hiring: candidates and companies use different vocabularies when describing skills and requirements. Our system bridges this gap using **job postings** as a translator, enriching company profiles to speak the same "skills language" as candidates.
23
+
24
+ ### Key Innovation
25
+ - **Candidates** describe: "Python, Machine Learning, Data Science"
26
+ - **Companies** describe: "Tech company, innovation, growth"
27
+ - **Job Postings** translate: "We need Python, AWS, TensorFlow"
28
+ - **Result**: Accurate matching in the same embedding space ℝ³⁸⁴
29
+
30
+ ---
31
+
32
+ ## 🚀 Features
33
+
34
+ - ✅ **Bilateral Matching**: Both candidates and companies get matched recommendations
35
+ - ✅ **NLP-Powered**: Uses sentence transformers for semantic understanding
36
+ - ✅ **Interactive Visualization**: Network graphs showing match connections
37
+ - ✅ **Scalable**: Handles 9,544 candidates × 180,000 companies
38
+ - ✅ **Real-time**: Fast similarity computation using cosine similarity
39
+ - ✅ **Professional UI**: Clean Streamlit interface
40
+
41
+ ---
42
+
43
+ ## 📁 Project Structure
44
+
45
+ ```
46
+ hrhub/
47
+ ├── app.py # Main Streamlit application
48
+ ├── config.py # Configuration settings
49
+ ├── requirements.txt # Python dependencies
50
+ ├── README.md # This file
51
+ ├── data/
52
+ │ ├── mock_data.py # Demo data (MVP)
53
+ │ ├── data_loader.py # Real data loader (future)
54
+ │ └── embeddings/ # Saved embeddings (future)
55
+ ├── utils/
56
+ │ ├── matching.py # Cosine similarity algorithms
57
+ │ ├── visualization.py # Network graph generation
58
+ │ └── display.py # UI components
59
+ └── assets/
60
+ └── style.css # Custom CSS (optional)
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 🛠️ Installation & Setup
66
+
67
+ ### Prerequisites
68
+ - Python 3.8+
69
+ - pip package manager
70
+ - Git
71
+
72
+ ### Local Development
73
+
74
+ 1. **Clone the repository**
75
+ ```bash
76
+ git clone https://github.com/your-username/hrhub.git
77
+ cd hrhub
78
+ ```
79
+
80
+ 2. **Create virtual environment** (recommended)
81
+ ```bash
82
+ python -m venv venv
83
+ source venv/bin/activate # On Windows: venv\Scripts\activate
84
+ ```
85
+
86
+ 3. **Install dependencies**
87
+ ```bash
88
+ pip install -r requirements.txt
89
+ ```
90
+
91
+ 4. **Run the app**
92
+ ```bash
93
+ streamlit run app.py
94
+ ```
95
+
96
+ 5. **Open browser**
97
+ Navigate to `http://localhost:8501`
98
+
99
+ ---
100
+
101
+ ## 🌐 Deployment (Streamlit Cloud)
102
+
103
+ ### Step 1: Push to GitHub
104
+ ```bash
105
+ git add .
106
+ git commit -m "Initial commit"
107
+ git push origin main
108
+ ```
109
+
110
+ ### Step 2: Deploy on Streamlit Cloud
111
+ 1. Go to [share.streamlit.io](https://share.streamlit.io)
112
+ 2. Sign in with GitHub
113
+ 3. Click "New app"
114
+ 4. Select your repository: `hrhub`
115
+ 5. Main file path: `app.py`
116
+ 6. Click "Deploy"
117
+
118
+ **That's it!** Your app will be live at `https://your-app.streamlit.app`
119
+
120
+ ---
121
+
122
+ ## 📊 Data Pipeline
123
+
124
+ ### Current (MVP - Hardcoded)
125
+ ```
126
+ mock_data.py → app.py → Display
127
+ ```
128
+
129
+ ### Future (Production)
130
+ ```
131
+ CSV Files → Data Processing → Embeddings → Saved Files
132
+
133
+ app.py loads embeddings → Real-time matching
134
+ ```
135
+
136
+ ### Files to Generate (Next Phase)
137
+ ```python
138
+ # After running your main code, save these:
139
+ 1. candidate_embeddings.npy # 9,544 × 384 array
140
+ 2. company_embeddings.npy # 180,000 × 384 array
141
+ 3. candidates_processed.pkl # Full candidate data
142
+ 4. companies_processed.pkl # Full company data
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 🔄 Switching from Mock to Real Data
148
+
149
+ ### Current Code (MVP)
150
+ ```python
151
+ # app.py
152
+ from data.mock_data import get_candidate_data, get_company_matches
153
+ ```
154
+
155
+ ### After Generating Embeddings
156
+ ```python
157
+ # app.py
158
+ from data.data_loader import get_candidate_data, get_company_matches
159
+ ```
160
+
161
+ **That's it!** No other code changes needed. The UI stays the same.
162
+
163
+ ---
164
+
165
+ ## 🎨 Configuration
166
+
167
+ Edit `config.py` to customize:
168
+
169
+ ```python
170
+ # Matching Settings
171
+ DEFAULT_TOP_K = 10 # Number of matches to show
172
+ MIN_SIMILARITY_SCORE = 0.5 # Minimum score threshold
173
+ EMBEDDING_DIMENSION = 384 # Vector dimension
174
+
175
+ # UI Settings
176
+ NETWORK_GRAPH_HEIGHT = 600 # Graph height in pixels
177
+
178
+ # Demo Mode
179
+ DEMO_MODE = True # Set False for production
180
+ ```
181
+
182
+ ---
183
+
184
+ ## 📈 Technical Details
185
+
186
+ ### Algorithm
187
+ 1. **Text Representation**: Convert candidate/company data to structured text
188
+ 2. **Embedding**: Use sentence transformers (`all-MiniLM-L6-v2`)
189
+ 3. **Similarity**: Compute cosine similarity between vectors
190
+ 4. **Ranking**: Sort by similarity score, return top K
191
+
192
+ ### Why Cosine Similarity?
193
+ - ✅ **Scale-invariant**: Focuses on direction, not magnitude
194
+ - ✅ **Profile shape matching**: Captures proportional skill distributions
195
+ - ✅ **Fast computation**: Optimized for large-scale matching
196
+ - ✅ **Proven in NLP**: Standard metric for semantic similarity
197
+
198
+ ### Performance
199
+ - **Loading time**: < 5 seconds (with pre-computed embeddings)
200
+ - **Matching speed**: < 1 second for 180K companies
201
+ - **Memory usage**: ~500MB (embeddings loaded)
202
+
203
+ ---
204
+
205
+ ## 🧪 Testing
206
+
207
+ ### Test Mock Data
208
+ ```bash
209
+ cd hrhub
210
+ python data/mock_data.py
211
+ ```
212
+
213
+ Expected output:
214
+ ```
215
+ ✅ Candidate: Demo Candidate #0
216
+ ✅ Top 5 matches loaded
217
+ ✅ Graph data: 6 nodes, 5 edges
218
+ ```
219
+
220
+ ### Test Streamlit App
221
+ ```bash
222
+ streamlit run app.py
223
+ ```
224
+
225
+ ---
226
+
227
+ ## 🎯 Roadmap
228
+
229
+ ### ✅ Phase 1: MVP (Current)
230
+ - [x] Basic matching logic
231
+ - [x] Streamlit UI
232
+ - [x] Network visualization
233
+ - [x] Hardcoded demo data
234
+
235
+ ### 🔄 Phase 2: Production (Next)
236
+ - [ ] Generate real embeddings
237
+ - [ ] Load embeddings from files
238
+ - [ ] Dynamic candidate selection
239
+ - [ ] Search functionality
240
+
241
+ ### 🚀 Phase 3: Advanced (Future)
242
+ - [ ] User authentication
243
+ - [ ] Company login view
244
+ - [ ] Weighted matching (different dimensions)
245
+ - [ ] RAG-powered recommendations
246
+ - [ ] Email notifications
247
+ - [ ] Analytics dashboard
248
+
249
+ ---
250
+
251
+ ## 👥 Team
252
+
253
+ **Master's in Business Data Science - Aalborg University**
254
+
255
+ - Roger - Project Lead & Deployment
256
+ - Eskil - [Role]
257
+ - [Team Member 3] - [Role]
258
+ - [Team Member 4] - [Role]
259
+
260
+ ---
261
+
262
+ ## 📝 License
263
+
264
+ This project is part of an academic course at Aalborg University.
265
+
266
+ ---
267
+
268
+ ## 🤝 Contributing
269
+
270
+ This is an academic project. Contributions are welcome after project submission (December 14, 2024).
271
+
272
+ ---
273
+
274
+ ## 📧 Contact
275
+
276
+ For questions or feedback:
277
+ - Create an issue on GitHub
278
+ - Contact via Moodle course forum
279
+
280
+ ---
281
+
282
+ ## 🙏 Acknowledgments
283
+
284
+ - **Sentence Transformers**: Hugging Face team
285
+ - **Streamlit**: Amazing framework for data apps
286
+ - **PyVis**: Interactive network visualization
287
+ - **Course Instructors**: For guidance and support
288
+
289
+ ---
290
+
291
+ **Last Updated**: December 2024
292
+ **Status**: 🟢 Active Development
data/notebooks/HRHUB_Complete_With_Postings.ipynb ADDED
@@ -0,0 +1,865 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# 🚀 HRHUB - Complete Bilateral Matching System\n",
8
+ "\n",
9
+ "## 🎯 System Architecture:\n",
10
+ "\n",
11
+ "```\n",
12
+ "Candidates (9.5K) ←→ Postings (700) ←→ Companies (180K)\n",
13
+ " ↓ ↓ ↓\n",
14
+ " Skills text Job requirements Enriched profiles\n",
15
+ " ↓ ↓ ↓\n",
16
+ " Embeddings ←―――――― SAME SPACE ℝ³⁸⁴ ―――――→\n",
17
+ "```\n",
18
+ "\n",
19
+ "## 🔑 Key Innovation:\n",
20
+ "\n",
21
+ "**Use postings to enrich company profiles** so they speak the same language as candidates!\n",
22
+ "\n",
23
+ "- Companies describe: \"We are in tech industry\"\n",
24
+ "- Postings translate: \"We need Python, AWS, React\"\n",
25
+ "- Result: Companies can match with candidates!\n",
26
+ "\n",
27
+ "---"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "markdown",
32
+ "metadata": {},
33
+ "source": [
34
+ "## 📦 Step 1: Install & Import"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": null,
40
+ "metadata": {},
41
+ "outputs": [],
42
+ "source": [
43
+ "!pip install -q sentence-transformers plotly anthropic scikit-learn umap-learn\n",
44
+ "\n",
45
+ "import pandas as pd\n",
46
+ "import numpy as np\n",
47
+ "from sentence_transformers import SentenceTransformer\n",
48
+ "import plotly.express as px\n",
49
+ "import plotly.graph_objects as go\n",
50
+ "from sklearn.manifold import TSNE\n",
51
+ "import warnings\n",
52
+ "warnings.filterwarnings('ignore')\n",
53
+ "\n",
54
+ "print(\"✅ All packages ready!\")"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "markdown",
59
+ "metadata": {},
60
+ "source": [
61
+ "## 📂 Step 2: Load ALL Datasets"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "code",
66
+ "execution_count": null,
67
+ "metadata": {},
68
+ "outputs": [],
69
+ "source": [
70
+ "print(\"📂 Loading all datasets...\\n\")\n",
71
+ "print(\"=\" * 70)\n",
72
+ "\n",
73
+ "# Load candidates\n",
74
+ "candidates = pd.read_csv('resume_data.csv')\n",
75
+ "print(f\"✅ Candidates: {len(candidates):,} rows × {len(candidates.columns)} columns\")\n",
76
+ "\n",
77
+ "# Load companies base\n",
78
+ "companies_base = pd.read_csv('companies/companies.csv')\n",
79
+ "print(f\"✅ Companies (base): {len(companies_base):,} rows\")\n",
80
+ "\n",
81
+ "# Load company enrichment data\n",
82
+ "company_industries = pd.read_csv('companies/company_industries.csv')\n",
83
+ "print(f\"✅ Company industries: {len(company_industries):,} rows\")\n",
84
+ "\n",
85
+ "company_specialties = pd.read_csv('companies/company_specialties.csv')\n",
86
+ "print(f\"✅ Company specialties: {len(company_specialties):,} rows\")\n",
87
+ "\n",
88
+ "employee_counts = pd.read_csv('companies/employee_counts.csv')\n",
89
+ "print(f\"✅ Employee counts: {len(employee_counts):,} rows\")\n",
90
+ "\n",
91
+ "# Load POSTINGS (THE BRIDGE!)\n",
92
+ "postings = pd.read_csv('postings.csv', on_bad_lines='skip')\n",
93
+ "print(f\"✅ Postings: {len(postings):,} rows × {len(postings.columns)} columns\")\n",
94
+ "\n",
95
+ "# Load job-related tables\n",
96
+ "try:\n",
97
+ " job_skills = pd.read_csv('jobs/job_skills.csv')\n",
98
+ " print(f\"✅ Job skills: {len(job_skills):,} rows\")\n",
99
+ "except:\n",
100
+ " job_skills = None\n",
101
+ " print(\"⚠️ Job skills not found (optional)\")\n",
102
+ "\n",
103
+ "try:\n",
104
+ " job_industries = pd.read_csv('jobs/job_industries.csv')\n",
105
+ " print(f\"✅ Job industries: {len(job_industries):,} rows\")\n",
106
+ "except:\n",
107
+ " job_industries = None\n",
108
+ " print(\"⚠️ Job industries not found (optional)\")\n",
109
+ "\n",
110
+ "print(\"\\n\" + \"=\" * 70)\n",
111
+ "print(\"✅ All datasets loaded!\\n\")"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "markdown",
116
+ "metadata": {},
117
+ "source": [
118
+ "## 🔗 Step 3: Merge Company Data"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": null,
124
+ "metadata": {},
125
+ "outputs": [],
126
+ "source": [
127
+ "print(\"🔗 Merging company data...\\n\")\n",
128
+ "\n",
129
+ "# Aggregate industries\n",
130
+ "company_industries_agg = company_industries.groupby('company_id')['industry_id'].apply(\n",
131
+ " lambda x: ', '.join(map(str, x.tolist()))\n",
132
+ ").reset_index()\n",
133
+ "company_industries_agg.columns = ['company_id', 'industries_list']\n",
134
+ "print(f\"✅ Aggregated industries for {len(company_industries_agg):,} companies\")\n",
135
+ "\n",
136
+ "# Aggregate specialties\n",
137
+ "company_specialties_agg = company_specialties.groupby('company_id')['specialty'].apply(\n",
138
+ " lambda x: ' | '.join(x.astype(str).tolist())\n",
139
+ ").reset_index()\n",
140
+ "company_specialties_agg.columns = ['company_id', 'specialties_list']\n",
141
+ "print(f\"✅ Aggregated specialties for {len(company_specialties_agg):,} companies\")\n",
142
+ "\n",
143
+ "# Start with base\n",
144
+ "companies_merged = companies_base.copy()\n",
145
+ "\n",
146
+ "# Merge industries\n",
147
+ "companies_merged = companies_merged.merge(\n",
148
+ " company_industries_agg, \n",
149
+ " on='company_id', \n",
150
+ " how='left'\n",
151
+ ")\n",
152
+ "\n",
153
+ "# Merge specialties\n",
154
+ "companies_merged = companies_merged.merge(\n",
155
+ " company_specialties_agg, \n",
156
+ " on='company_id', \n",
157
+ " how='left'\n",
158
+ ")\n",
159
+ "\n",
160
+ "# Merge employee counts\n",
161
+ "companies_merged = companies_merged.merge(\n",
162
+ " employee_counts, \n",
163
+ " on='company_id', \n",
164
+ " how='left'\n",
165
+ ")\n",
166
+ "\n",
167
+ "print(f\"\\n✅ Base company merge complete: {len(companies_merged):,} companies\")\n",
168
+ "print(f\"📊 Columns: {companies_merged.columns.tolist()[:10]}...\\n\")"
169
+ ]
170
+ },
171
+ {
172
+ "cell_type": "markdown",
173
+ "metadata": {},
174
+ "source": [
175
+ "## 🌉 Step 4: Enrich Companies with Postings (THE BRIDGE!)\n",
176
+ "\n",
177
+ "**This is the key step!** Postings tell us what companies actually need."
178
+ ]
179
+ },
180
+ {
181
+ "cell_type": "code",
182
+ "execution_count": null,
183
+ "metadata": {},
184
+ "outputs": [],
185
+ "source": [
186
+ "print(\"🌉 Enriching companies with job posting data...\\n\")\n",
187
+ "print(\"=\" * 70)\n",
188
+ "print(\"KEY INSIGHT: Postings contain the 'requirements language'\")\n",
189
+ "print(\"that bridges companies and candidates!\")\n",
190
+ "print(\"=\" * 70 + \"\\n\")\n",
191
+ "\n",
192
+ "# Clean postings\n",
193
+ "postings = postings.fillna('')\n",
194
+ "\n",
195
+ "# Aggregate postings per company\n",
196
+ "postings_agg = postings.groupby('company_id').agg({\n",
197
+ " 'title': lambda x: ' | '.join(x.astype(str).tolist()[:10]), # Top 10 job titles\n",
198
+ " 'description': lambda x: ' '.join(x.astype(str).tolist()[:5]), # Top 5 descriptions (truncated)\n",
199
+ " 'skills_desc': lambda x: ' | '.join(x.dropna().astype(str).tolist()), # All skills\n",
200
+ " 'formatted_experience_level': lambda x: ' | '.join(x.dropna().unique().astype(str)),\n",
201
+ " 'formatted_work_type': lambda x: ' | '.join(x.dropna().unique().astype(str))\n",
202
+ "}).reset_index()\n",
203
+ "\n",
204
+ "postings_agg.columns = [\n",
205
+ " 'company_id', \n",
206
+ " 'posted_job_titles', \n",
207
+ " 'posted_descriptions',\n",
208
+ " 'required_skills',\n",
209
+ " 'experience_levels',\n",
210
+ " 'work_types'\n",
211
+ "]\n",
212
+ "\n",
213
+ "print(f\"✅ Aggregated postings for {len(postings_agg):,} companies\")\n",
214
+ "print(f\"\\n💡 These {len(postings_agg):,} companies have explicit requirements!\\n\")\n",
215
+ "\n",
216
+ "# Merge postings into companies\n",
217
+ "companies_full = companies_merged.merge(\n",
218
+ " postings_agg,\n",
219
+ " on='company_id',\n",
220
+ " how='left'\n",
221
+ ")\n",
222
+ "\n",
223
+ "# Fill NaN\n",
224
+ "companies_full = companies_full.fillna('')\n",
225
+ "\n",
226
+ "print(f\"✅ ENRICHED COMPANIES CREATED!\")\n",
227
+ "print(f\"📊 Final: {len(companies_full):,} companies × {len(companies_full.columns)} columns\")\n",
228
+ "print(f\"\\n📋 New columns from postings:\")\n",
229
+ "print(f\" - posted_job_titles\")\n",
230
+ "print(f\" - posted_descriptions\")\n",
231
+ "print(f\" - required_skills ← KEY FOR MATCHING!\")\n",
232
+ "print(f\" - experience_levels\")\n",
233
+ "print(f\" - work_types\\n\")\n",
234
+ "\n",
235
+ "# Show sample\n",
236
+ "print(\"👀 Sample enriched company:\")\n",
237
+ "sample_with_postings = companies_full[companies_full['required_skills'] != ''].iloc[0]\n",
238
+ "print(f\"\\nCompany: {sample_with_postings.get('name', 'N/A')}\")\n",
239
+ "print(f\"Industries: {str(sample_with_postings.get('industries_list', ''))[:100]}...\")\n",
240
+ "print(f\"Required Skills: {str(sample_with_postings.get('required_skills', ''))[:100]}...\")\n",
241
+ "print(f\"Job Titles Posted: {str(sample_with_postings.get('posted_job_titles', ''))[:100]}...\")"
242
+ ]
243
+ },
244
+ {
245
+ "cell_type": "markdown",
246
+ "metadata": {},
247
+ "source": [
248
+ "## 📂 Step 5: Load & Clean Candidates"
249
+ ]
250
+ },
251
+ {
252
+ "cell_type": "code",
253
+ "execution_count": null,
254
+ "metadata": {},
255
+ "outputs": [],
256
+ "source": [
257
+ "# Clean candidates\n",
258
+ "candidates = candidates.fillna('')\n",
259
+ "\n",
260
+ "print(f\"✅ Candidates cleaned: {len(candidates):,} rows\")\n",
261
+ "print(f\"📋 Columns: {candidates.columns.tolist()[:10]}...\")\n",
262
+ "candidates.head(3)"
263
+ ]
264
+ },
265
+ {
266
+ "cell_type": "markdown",
267
+ "metadata": {},
268
+ "source": [
269
+ "## 📝 Step 6: Create Aligned Text Representations\n",
270
+ "\n",
271
+ "**CRITICAL:** Both entities must use the same vocabulary!"
272
+ ]
273
+ },
274
+ {
275
+ "cell_type": "code",
276
+ "execution_count": null,
277
+ "metadata": {},
278
+ "outputs": [],
279
+ "source": [
280
+ "print(\"📝 Creating ALIGNED text representations...\\n\")\n",
281
+ "print(\"=\" * 70)\n",
282
+ "print(\"ALIGNMENT STRATEGY:\")\n",
283
+ "print(\"• Candidates: Describe skills, experience, education\")\n",
284
+ "print(\"• Companies: Describe what they NEED (from postings!)\")\n",
285
+ "print(\"• Result: Both use 'skills language' → same vector space!\")\n",
286
+ "print(\"=\" * 70 + \"\\n\")\n",
287
+ "\n",
288
+ "# ========================================================================\n",
289
+ "# CANDIDATE TEXT - Professional offering\n",
290
+ "# ========================================================================\n",
291
+ "def make_candidate_text(row):\n",
292
+ " \"\"\"\n",
293
+ " Candidate text focuses on:\n",
294
+ " - What skills I have\n",
295
+ " - What experience I bring\n",
296
+ " - What value I offer\n",
297
+ " \"\"\"\n",
298
+ " parts = []\n",
299
+ " \n",
300
+ " # Professional identity\n",
301
+ " if row.get('career_objective'):\n",
302
+ " parts.append(f\"Professional seeking: {row['career_objective']}\")\n",
303
+ " \n",
304
+ " if row.get('job_position_name'):\n",
305
+ " parts.append(f\"Target role: {row['job_position_name']}\")\n",
306
+ " \n",
307
+ " # SKILLS (most important for matching!)\n",
308
+ " all_skills = []\n",
309
+ " if row.get('skills'): \n",
310
+ " all_skills.append(row['skills'])\n",
311
+ " if row.get('related_skills_in_job'): \n",
312
+ " all_skills.append(row['related_skills_in_job'])\n",
313
+ " if row.get('certification_skills'): \n",
314
+ " all_skills.append(row['certification_skills'])\n",
315
+ " if row.get('skills_required'): # Skills they're looking for in jobs\n",
316
+ " all_skills.append(row['skills_required'])\n",
317
+ " \n",
318
+ " if all_skills:\n",
319
+ " parts.append(f\"Skills and expertise: {' | '.join(all_skills)}\")\n",
320
+ " \n",
321
+ " # EXPERIENCE\n",
322
+ " if row.get('positions'):\n",
323
+ " parts.append(f\"Experience in roles: {row['positions']}\")\n",
324
+ " \n",
325
+ " if row.get('professional_company_names'):\n",
326
+ " parts.append(f\"Companies worked at: {row['professional_company_names']}\")\n",
327
+ " \n",
328
+ " if row.get('responsibilities'):\n",
329
+ " resp = str(row['responsibilities'])[:250]\n",
330
+ " parts.append(f\"Responsibilities: {resp}\")\n",
331
+ " \n",
332
+ " # EDUCATION\n",
333
+ " edu_parts = []\n",
334
+ " if row.get('degree_names'): \n",
335
+ " edu_parts.append(row['degree_names'])\n",
336
+ " if row.get('major_field_of_studies'): \n",
337
+ " edu_parts.append(f\"in {row['major_field_of_studies']}\")\n",
338
+ " if row.get('educational_institution_name'): \n",
339
+ " edu_parts.append(f\"from {row['educational_institution_name']}\")\n",
340
+ " \n",
341
+ " if edu_parts:\n",
342
+ " parts.append(f\"Education: {' '.join(edu_parts)}\")\n",
343
+ " \n",
344
+ " # ADDITIONAL\n",
345
+ " if row.get('languages'):\n",
346
+ " parts.append(f\"Languages: {row['languages']}\")\n",
347
+ " \n",
348
+ " if row.get('certification_providers'):\n",
349
+ " parts.append(f\"Certifications from: {row['certification_providers']}\")\n",
350
+ " \n",
351
+ " if row.get('extra_curricular_activity_types'):\n",
352
+ " parts.append(f\"Activities: {row['extra_curricular_activity_types']}\")\n",
353
+ " \n",
354
+ " return ' || '.join(parts) if parts else \"Professional profile\"\n",
355
+ "\n",
356
+ "\n",
357
+ "# ========================================================================\n",
358
+ "# COMPANY TEXT - Job requirements (enriched with postings!)\n",
359
+ "# ========================================================================\n",
360
+ "def make_company_text(row):\n",
361
+ " \"\"\"\n",
362
+ " Company text focuses on:\n",
363
+ " - What skills we need (from postings!)\n",
364
+ " - What roles we're hiring for\n",
365
+ " - What our company does\n",
366
+ " \"\"\"\n",
367
+ " parts = []\n",
368
+ " \n",
369
+ " # Company identity\n",
370
+ " if row.get('name'):\n",
371
+ " parts.append(f\"Company: {row['name']}\")\n",
372
+ " \n",
373
+ " # REQUIRED SKILLS (from postings - KEY!)\n",
374
+ " if row.get('required_skills'):\n",
375
+ " parts.append(f\"Looking for skills: {row['required_skills']}\")\n",
376
+ " \n",
377
+ " # JOB TITLES (from postings)\n",
378
+ " if row.get('posted_job_titles'):\n",
379
+ " parts.append(f\"Hiring for roles: {row['posted_job_titles']}\")\n",
380
+ " \n",
381
+ " # EXPERIENCE LEVELS (from postings)\n",
382
+ " if row.get('experience_levels'):\n",
383
+ " parts.append(f\"Experience levels: {row['experience_levels']}\")\n",
384
+ " \n",
385
+ " # Industries & specialties\n",
386
+ " if row.get('industries_list'):\n",
387
+ " parts.append(f\"Industries: {row['industries_list']}\")\n",
388
+ " \n",
389
+ " if row.get('specialties_list'):\n",
390
+ " parts.append(f\"Specialties: {row['specialties_list']}\")\n",
391
+ " \n",
392
+ " # Company description\n",
393
+ " if row.get('description'):\n",
394
+ " desc = str(row['description'])[:300]\n",
395
+ " parts.append(f\"About: {desc}\")\n",
396
+ " \n",
397
+ " # Posted descriptions (gives context)\n",
398
+ " if row.get('posted_descriptions'):\n",
399
+ " posted_desc = str(row['posted_descriptions'])[:200]\n",
400
+ " parts.append(f\"Job descriptions: {posted_desc}\")\n",
401
+ " \n",
402
+ " # Company size\n",
403
+ " if row.get('employee_count'):\n",
404
+ " parts.append(f\"Company size: {row['employee_count']} employees\")\n",
405
+ " \n",
406
+ " # Location\n",
407
+ " loc = []\n",
408
+ " if row.get('city'): loc.append(row['city'])\n",
409
+ " if row.get('state'): loc.append(row['state'])\n",
410
+ " if row.get('country'): loc.append(row['country'])\n",
411
+ " if loc:\n",
412
+ " parts.append(f\"Location: {', '.join(loc)}\")\n",
413
+ " \n",
414
+ " # Work types\n",
415
+ " if row.get('work_types'):\n",
416
+ " parts.append(f\"Work arrangement: {row['work_types']}\")\n",
417
+ " \n",
418
+ " return ' || '.join(parts) if parts else \"Company profile\"\n",
419
+ "\n",
420
+ "\n",
421
+ "# ========================================================================\n",
422
+ "# APPLY TO DATAFRAMES\n",
423
+ "# ========================================================================\n",
424
+ "print(\"🔄 Generating candidate texts...\")\n",
425
+ "candidates['text'] = candidates.apply(make_candidate_text, axis=1)\n",
426
+ "\n",
427
+ "print(\"🔄 Generating company texts...\")\n",
428
+ "companies_full['text'] = companies_full.apply(make_company_text, axis=1)\n",
429
+ "\n",
430
+ "print(\"\\n✅ ALIGNED texts created!\\n\")\n",
431
+ "\n",
432
+ "# Compare vocabularies\n",
433
+ "print(\"=\" * 70)\n",
434
+ "print(\"CANDIDATE SAMPLE:\")\n",
435
+ "print(candidates['text'].iloc[0][:500])\n",
436
+ "print(\"\\n\" + \"=\" * 70)\n",
437
+ "print(\"COMPANY SAMPLE (with postings data):\")\n",
438
+ "# Find company with postings\n",
439
+ "company_with_postings = companies_full[companies_full['required_skills'] != ''].iloc[0]\n",
440
+ "print(company_with_postings['text'][:500])\n",
441
+ "print(\"=\" * 70)\n",
442
+ "\n",
443
+ "print(\"\\n💡 Notice: Both now use SKILLS LANGUAGE!\")\n",
444
+ "print(\" Candidate: 'Skills and expertise: Python, Java'\")\n",
445
+ "print(\" Company: 'Looking for skills: Python, AWS'\")\n",
446
+ "print(\" → They can now be compared in the same space!\\n\")"
447
+ ]
448
+ },
449
+ {
450
+ "cell_type": "markdown",
451
+ "metadata": {},
452
+ "source": [
453
+ "## 🧠 Step 7: Generate Embeddings (ℝ³⁸⁴)\n",
454
+ "\n",
455
+ "Transform aligned text → vectors in same mathematical space"
456
+ ]
457
+ },
458
+ {
459
+ "cell_type": "code",
460
+ "execution_count": null,
461
+ "metadata": {},
462
+ "outputs": [],
463
+ "source": [
464
+ "print(\"🧠 Loading embedding model...\\n\")\n",
465
+ "model = SentenceTransformer('all-MiniLM-L6-v2')\n",
466
+ "\n",
467
+ "embedding_dim = model.get_sentence_embedding_dimension()\n",
468
+ "print(f\"✅ Model loaded! Embedding dimension: ℝ^{embedding_dim}\\n\")\n",
469
+ "\n",
470
+ "print(\"🔄 Generating candidate vectors...\")\n",
471
+ "print(f\" ({len(candidates):,} candidates × ~2-3 minutes)\\n\")\n",
472
+ "cand_vectors = model.encode(\n",
473
+ " candidates['text'].tolist(), \n",
474
+ " show_progress_bar=True,\n",
475
+ " batch_size=32\n",
476
+ ")\n",
477
+ "\n",
478
+ "print(\"\\n🔄 Generating company vectors...\")\n",
479
+ "print(f\" ({len(companies_full):,} companies × ~15-20 minutes)\\n\")\n",
480
+ "comp_vectors = model.encode(\n",
481
+ " companies_full['text'].tolist(), \n",
482
+ " show_progress_bar=True,\n",
483
+ " batch_size=64\n",
484
+ ")\n",
485
+ "\n",
486
+ "print(\"\\n\" + \"=\" * 70)\n",
487
+ "print(\"✅ VECTORS CREATED IN SAME SPACE!\")\n",
488
+ "print(\"=\" * 70)\n",
489
+ "print(f\"📊 Candidate vectors: {cand_vectors.shape}\")\n",
490
+ "print(f\"📊 Company vectors: {comp_vectors.shape}\")\n",
491
+ "print(f\"\\n🎯 Both live in ℝ^{embedding_dim}!\")\n",
492
+ "print(f\"🎯 Now companies with 'Python' requirements will be\")\n",
493
+ "print(f\" CLOSE to candidates with 'Python' skills!\\n\")"
494
+ ]
495
+ },
496
+ {
497
+ "cell_type": "markdown",
498
+ "metadata": {},
499
+ "source": [
500
+ "## 🎯 Step 8: Matching Engine"
501
+ ]
502
+ },
503
+ {
504
+ "cell_type": "code",
505
+ "execution_count": null,
506
+ "metadata": {},
507
+ "outputs": [],
508
+ "source": [
509
+ "def cosine_similarity(a, b):\n",
510
+ " \"\"\"Calculate cosine similarity between two vectors.\"\"\"\n",
511
+ " return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))\n",
512
+ "\n",
513
+ "def find_top_matches(candidate_idx, top_k=10):\n",
514
+ " \"\"\"\n",
515
+ " Find top K company matches for a candidate.\n",
516
+ " \n",
517
+ " Returns: List of (company_idx, similarity_score)\n",
518
+ " \"\"\"\n",
519
+ " cand_vec = cand_vectors[candidate_idx]\n",
520
+ " \n",
521
+ " scores = []\n",
522
+ " for i, comp_vec in enumerate(comp_vectors):\n",
523
+ " score = cosine_similarity(cand_vec, comp_vec)\n",
524
+ " scores.append((i, score))\n",
525
+ " \n",
526
+ " scores.sort(key=lambda x: x[1], reverse=True)\n",
527
+ " return scores[:top_k]\n",
528
+ "\n",
529
+ "print(\"✅ Matching engine ready!\")\n",
530
+ "print(f\"📊 Can match {len(candidates):,} candidates with {len(companies_full):,} companies\\n\")"
531
+ ]
532
+ },
533
+ {
534
+ "cell_type": "markdown",
535
+ "metadata": {},
536
+ "source": [
537
+ "## 🔍 Step 9: Test Matching"
538
+ ]
539
+ },
540
+ {
541
+ "cell_type": "code",
542
+ "execution_count": null,
543
+ "metadata": {},
544
+ "outputs": [],
545
+ "source": [
546
+ "print(\"🔍 Finding top 10 matches for Candidate #0...\\n\")\n",
547
+ "\n",
548
+ "matches = find_top_matches(0, top_k=10)\n",
549
+ "\n",
550
+ "print(\"🎯 Top 10 Company Matches:\\n\")\n",
551
+ "print(\"=\" * 90)\n",
552
+ "print(f\"{'Rank':<6} {'Score':<8} {'Company':<35} {'Skills Needed':<40}\")\n",
553
+ "print(\"=\" * 90)\n",
554
+ "\n",
555
+ "for rank, (comp_idx, score) in enumerate(matches, 1):\n",
556
+ " company = companies_full.iloc[comp_idx]\n",
557
+ " name = company.get('name', 'N/A')[:33]\n",
558
+ " skills = company.get('required_skills', 'N/A')[:38]\n",
559
+ " print(f\"{rank:<6} {score:.4f} {name:<35} {skills}\")\n",
560
+ "\n",
561
+ "print(\"=\" * 90)\n",
562
+ "\n",
563
+ "print(\"\\n💡 If scores are good (>0.5), the alignment worked!\")\n",
564
+ "print(\" High scores = Company needs match candidate skills\\n\")"
565
+ ]
566
+ },
567
+ {
568
+ "cell_type": "markdown",
569
+ "metadata": {},
570
+ "source": [
571
+ "## 📊 Step 10: Visualize Vector Space\n",
572
+ "\n",
573
+ "See where candidates and companies live in ℝ³⁸⁴ (projected to ℝ²)"
574
+ ]
575
+ },
576
+ {
577
+ "cell_type": "code",
578
+ "execution_count": null,
579
+ "metadata": {},
580
+ "outputs": [],
581
+ "source": [
582
+ "print(\"🎨 VECTOR SPACE VISUALIZATION\\n\")\n",
583
+ "print(\"=\" * 70)\n",
584
+ "\n",
585
+ "# Sample for visualization\n",
586
+ "n_cand_viz = min(500, len(candidates))\n",
587
+ "n_comp_viz = min(2000, len(companies_full))\n",
588
+ "\n",
589
+ "print(f\"📊 Visualizing:\")\n",
590
+ "print(f\" • {n_cand_viz} candidates\")\n",
591
+ "print(f\" • {n_comp_viz} companies\")\n",
592
+ "print(f\" • From ℝ^{embedding_dim} → ℝ² (t-SNE projection)\\n\")\n",
593
+ "\n",
594
+ "# Sample vectors\n",
595
+ "cand_sample = cand_vectors[:n_cand_viz]\n",
596
+ "comp_sample = comp_vectors[:n_comp_viz]\n",
597
+ "\n",
598
+ "# Combine\n",
599
+ "all_vectors = np.vstack([cand_sample, comp_sample])\n",
600
+ "\n",
601
+ "print(\"🔄 Running t-SNE (2-3 minutes)...\")\n",
602
+ "tsne = TSNE(\n",
603
+ " n_components=2,\n",
604
+ " perplexity=30,\n",
605
+ " random_state=42,\n",
606
+ " n_iter=1000,\n",
607
+ " verbose=1\n",
608
+ ")\n",
609
+ "\n",
610
+ "vectors_2d = tsne.fit_transform(all_vectors)\n",
611
+ "\n",
612
+ "# Split\n",
613
+ "cand_2d = vectors_2d[:n_cand_viz]\n",
614
+ "comp_2d = vectors_2d[n_cand_viz:]\n",
615
+ "\n",
616
+ "print(\"\\n✅ t-SNE complete!\\n\")"
617
+ ]
618
+ },
619
+ {
620
+ "cell_type": "code",
621
+ "execution_count": null,
622
+ "metadata": {},
623
+ "outputs": [],
624
+ "source": [
625
+ "# Create plot\n",
626
+ "fig = go.Figure()\n",
627
+ "\n",
628
+ "# Companies (red)\n",
629
+ "fig.add_trace(go.Scatter(\n",
630
+ " x=comp_2d[:, 0],\n",
631
+ " y=comp_2d[:, 1],\n",
632
+ " mode='markers',\n",
633
+ " name='Companies',\n",
634
+ " marker=dict(\n",
635
+ " size=6,\n",
636
+ " color='#ff6b6b',\n",
637
+ " opacity=0.6\n",
638
+ " ),\n",
639
+ " text=[f\"Company {i}: {companies_full.iloc[i].get('name', 'N/A')[:30]}\" \n",
640
+ " for i in range(n_comp_viz)],\n",
641
+ " hovertemplate='<b>%{text}</b><extra></extra>'\n",
642
+ "))\n",
643
+ "\n",
644
+ "# Candidates (green)\n",
645
+ "fig.add_trace(go.Scatter(\n",
646
+ " x=cand_2d[:, 0],\n",
647
+ " y=cand_2d[:, 1],\n",
648
+ " mode='markers',\n",
649
+ " name='Candidates',\n",
650
+ " marker=dict(\n",
651
+ " size=10,\n",
652
+ " color='#00ff00',\n",
653
+ " opacity=0.8,\n",
654
+ " line=dict(width=1, color='white')\n",
655
+ " ),\n",
656
+ " text=[f\"Candidate {i}\" for i in range(n_cand_viz)],\n",
657
+ " hovertemplate='<b>%{text}</b><extra></extra>'\n",
658
+ "))\n",
659
+ "\n",
660
+ "fig.update_layout(\n",
661
+ " title='Vector Space: Candidates & Companies (with Postings Enrichment)',\n",
662
+ " xaxis_title='Dimension 1',\n",
663
+ " yaxis_title='Dimension 2',\n",
664
+ " width=1200,\n",
665
+ " height=800,\n",
666
+ " plot_bgcolor='#1a1a1a',\n",
667
+ " paper_bgcolor='#0d0d0d',\n",
668
+ " font=dict(color='white')\n",
669
+ ")\n",
670
+ "\n",
671
+ "fig.show()\n",
672
+ "\n",
673
+ "print(\"✅ Visualization complete!\\n\")\n",
674
+ "print(\"💡 KEY OBSERVATIONS:\")\n",
675
+ "print(\" • Green = Candidates | Red = Companies\")\n",
676
+ "print(\" • If they OVERLAP → Good! Alignment worked!\")\n",
677
+ "print(\" • If still separated → Need more postings data\")\n",
678
+ "print(\" • Clusters = Similar skill profiles grouped\\n\")"
679
+ ]
680
+ },
681
+ {
682
+ "cell_type": "markdown",
683
+ "metadata": {},
684
+ "source": [
685
+ "## 🔍 Step 11: Highlight Specific Candidate + Matches"
686
+ ]
687
+ },
688
+ {
689
+ "cell_type": "code",
690
+ "execution_count": null,
691
+ "metadata": {},
692
+ "outputs": [],
693
+ "source": [
694
+ "target_candidate = 0\n",
695
+ "\n",
696
+ "print(f\"🔍 Analyzing Candidate #{target_candidate}...\\n\")\n",
697
+ "\n",
698
+ "matches = find_top_matches(target_candidate, top_k=10)\n",
699
+ "match_indices = [comp_idx for comp_idx, score in matches if comp_idx < n_comp_viz]\n",
700
+ "\n",
701
+ "# Create highlighted plot\n",
702
+ "fig2 = go.Figure()\n",
703
+ "\n",
704
+ "# All companies (background)\n",
705
+ "fig2.add_trace(go.Scatter(\n",
706
+ " x=comp_2d[:, 0],\n",
707
+ " y=comp_2d[:, 1],\n",
708
+ " mode='markers',\n",
709
+ " name='All Companies',\n",
710
+ " marker=dict(size=4, color='#ff6b6b', opacity=0.3),\n",
711
+ " showlegend=True\n",
712
+ "))\n",
713
+ "\n",
714
+ "# Top matches (highlighted)\n",
715
+ "if match_indices:\n",
716
+ " match_positions = comp_2d[match_indices]\n",
717
+ " fig2.add_trace(go.Scatter(\n",
718
+ " x=match_positions[:, 0],\n",
719
+ " y=match_positions[:, 1],\n",
720
+ " mode='markers',\n",
721
+ " name='Top Matches',\n",
722
+ " marker=dict(\n",
723
+ " size=15,\n",
724
+ " color='#ff0000',\n",
725
+ " line=dict(width=2, color='white')\n",
726
+ " ),\n",
727
+ " text=[f\"Match #{i+1}: {companies_full.iloc[match_indices[i]].get('name', 'N/A')[:30]}<br>Score: {matches[i][1]:.3f}\" \n",
728
+ " for i in range(len(match_indices))],\n",
729
+ " hovertemplate='<b>%{text}</b><extra></extra>'\n",
730
+ " ))\n",
731
+ "\n",
732
+ "# Target candidate\n",
733
+ "fig2.add_trace(go.Scatter(\n",
734
+ " x=[cand_2d[target_candidate, 0]],\n",
735
+ " y=[cand_2d[target_candidate, 1]],\n",
736
+ " mode='markers',\n",
737
+ " name=f'Candidate #{target_candidate}',\n",
738
+ " marker=dict(\n",
739
+ " size=25,\n",
740
+ " color='#00ff00',\n",
741
+ " symbol='star',\n",
742
+ " line=dict(width=3, color='white')\n",
743
+ " )\n",
744
+ "))\n",
745
+ "\n",
746
+ "# Connection lines\n",
747
+ "for i, match_idx in enumerate(match_indices[:5]):\n",
748
+ " fig2.add_trace(go.Scatter(\n",
749
+ " x=[cand_2d[target_candidate, 0], comp_2d[match_idx, 0]],\n",
750
+ " y=[cand_2d[target_candidate, 1], comp_2d[match_idx, 1]],\n",
751
+ " mode='lines',\n",
752
+ " line=dict(color='yellow', width=1, dash='dot'),\n",
753
+ " opacity=0.5,\n",
754
+ " showlegend=False\n",
755
+ " ))\n",
756
+ "\n",
757
+ "fig2.update_layout(\n",
758
+ " title=f'Candidate #{target_candidate} and Top Matches',\n",
759
+ " xaxis_title='Dimension 1',\n",
760
+ " yaxis_title='Dimension 2',\n",
761
+ " width=1200,\n",
762
+ " height=800,\n",
763
+ " plot_bgcolor='#1a1a1a',\n",
764
+ " paper_bgcolor='#0d0d0d',\n",
765
+ " font=dict(color='white')\n",
766
+ ")\n",
767
+ "\n",
768
+ "fig2.show()\n",
769
+ "\n",
770
+ "print(\"✅ Highlighted visualization created!\")\n",
771
+ "print(f\" ⭐ Green star = Candidate #{target_candidate}\")\n",
772
+ "print(f\" 🔴 Red dots = Top matches\")\n",
773
+ "print(f\" 💛 Yellow lines = Connections in vector space\\n\")"
774
+ ]
775
+ },
776
+ {
777
+ "cell_type": "markdown",
778
+ "metadata": {},
779
+ "source": [
780
+ "## 💾 Step 12: Export Results"
781
+ ]
782
+ },
783
+ {
784
+ "cell_type": "code",
785
+ "execution_count": null,
786
+ "metadata": {},
787
+ "outputs": [],
788
+ "source": [
789
+ "# Generate matches for sample\n",
790
+ "results = []\n",
791
+ "export_sample = min(500, len(candidates))\n",
792
+ "\n",
793
+ "print(f\"💾 Generating matches for {export_sample} candidates...\\n\")\n",
794
+ "\n",
795
+ "for i in range(export_sample):\n",
796
+ " if i % 50 == 0:\n",
797
+ " print(f\" Progress: {i}/{export_sample}\")\n",
798
+ " \n",
799
+ " matches = find_top_matches(i, top_k=10)\n",
800
+ " \n",
801
+ " for rank, (comp_idx, score) in enumerate(matches, 1):\n",
802
+ " company = companies_full.iloc[comp_idx]\n",
803
+ " results.append({\n",
804
+ " 'candidate_id': i,\n",
805
+ " 'company_id': company.get('company_id'),\n",
806
+ " 'company_name': company.get('name', 'N/A'),\n",
807
+ " 'rank': rank,\n",
808
+ " 'similarity_score': float(score),\n",
809
+ " 'required_skills': company.get('required_skills', 'N/A')[:100],\n",
810
+ " 'posted_jobs': company.get('posted_job_titles', 'N/A')[:100]\n",
811
+ " })\n",
812
+ "\n",
813
+ "results_df = pd.DataFrame(results)\n",
814
+ "results_df.to_csv('hrhub_matches_with_postings.csv', index=False)\n",
815
+ "\n",
816
+ "print(f\"\\n✅ Exported {len(results_df):,} matches!\")\n",
817
+ "print(f\"📄 File: hrhub_matches_with_postings.csv\\n\")\n",
818
+ "results_df.head(20)"
819
+ ]
820
+ },
821
+ {
822
+ "cell_type": "markdown",
823
+ "metadata": {},
824
+ "source": [
825
+ "## 🎉 COMPLETE!\n",
826
+ "\n",
827
+ "### ✅ What you have:\n",
828
+ "\n",
829
+ "1. **Enriched companies** with job posting data (requirements, skills needed)\n",
830
+ "2. **Aligned text representations** (both use \"skills language\")\n",
831
+ "3. **Vectors in same space** ℝ³⁸⁴\n",
832
+ "4. **Cosine similarity matching**\n",
833
+ "5. **Vector space visualization**\n",
834
+ "6. **Exported results**\n",
835
+ "\n",
836
+ "### 🚀 Next steps:\n",
837
+ "\n",
838
+ "1. **Train LLM on patterns:** \"Company in industry X historically needs skills Y\"\n",
839
+ "2. **Predict for companies without postings:** Use learned patterns\n",
840
+ "3. **Add weights:** Let users tune dimension importance\n",
841
+ "4. **Build UI:** Interactive matching interface\n",
842
+ "5. **LLM explanations:** Why these matches make sense\n",
843
+ "\n",
844
+ "### 💡 Key insight achieved:\n",
845
+ "\n",
846
+ "**Postings bridge the gap!** They translate \"what companies are\" into \"what companies need\" - the same language candidates speak!\n",
847
+ "\n",
848
+ "---"
849
+ ]
850
+ }
851
+ ],
852
+ "metadata": {
853
+ "kernelspec": {
854
+ "display_name": "Python 3",
855
+ "language": "python",
856
+ "name": "python3"
857
+ },
858
+ "language_info": {
859
+ "name": "python",
860
+ "version": "3.8.0"
861
+ }
862
+ },
863
+ "nbformat": 4,
864
+ "nbformat_minor": 4
865
+ }
data/notebooks/HRHUB_Full_180K.ipynb ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# 🚀 HRHUB - Bilateral Matching System\n",
8
+ "\n",
9
+ "## 🎯 Mathematical Framework:\n",
10
+ "\n",
11
+ "```\n",
12
+ "Candidate ∈ ℝⁿ (multidimensional vector)\n",
13
+ "Company ∈ ℝⁿ (multidimensional vector)\n",
14
+ "\n",
15
+ "Both live in the SAME vector space!\n",
16
+ "\n",
17
+ "Match Score = cosine_similarity(v_candidate, v_company)\n",
18
+ "```\n",
19
+ "\n",
20
+ "## 📊 Dataset:\n",
21
+ "- **9,544 candidates** (35 dimensions)\n",
22
+ "- **180,000 companies** (multiple dimensions from merged data)\n",
23
+ "\n",
24
+ "---"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "markdown",
29
+ "metadata": {},
30
+ "source": [
31
+ "## 📦 Step 1: Install & Import"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": null,
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "!pip install -q sentence-transformers plotly anthropic\n",
41
+ "\n",
42
+ "import pandas as pd\n",
43
+ "import numpy as np\n",
44
+ "from sentence_transformers import SentenceTransformer\n",
45
+ "import plotly.express as px\n",
46
+ "import warnings\n",
47
+ "warnings.filterwarnings('ignore')\n",
48
+ "\n",
49
+ "print(\"✅ Ready!\")"
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "markdown",
54
+ "metadata": {},
55
+ "source": [
56
+ "## 📂 Step 2: Load & Merge Company Data\n",
57
+ "\n",
58
+ "Building rich 180K company entities by merging multiple tables."
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "code",
63
+ "execution_count": null,
64
+ "metadata": {},
65
+ "outputs": [],
66
+ "source": [
67
+ "print(\"📂 Loading company datasets...\\n\")\n",
68
+ "\n",
69
+ "# Load base companies table\n",
70
+ "companies_base = pd.read_csv('companies/companies.csv')\n",
71
+ "print(f\"✅ Base companies: {len(companies_base):,} rows\")\n",
72
+ "\n",
73
+ "# Load additional company dimensions\n",
74
+ "company_industries = pd.read_csv('companies/company_industries.csv')\n",
75
+ "print(f\"✅ Company industries: {len(company_industries):,} rows\")\n",
76
+ "\n",
77
+ "company_specialties = pd.read_csv('companies/company_specialties.csv')\n",
78
+ "print(f\"✅ Company specialties: {len(company_specialties):,} rows\")\n",
79
+ "\n",
80
+ "employee_counts = pd.read_csv('companies/employee_counts.csv')\n",
81
+ "print(f\"✅ Employee counts: {len(employee_counts):,} rows\")\n",
82
+ "\n",
83
+ "# Load mappings (for reference)\n",
84
+ "industries_map = pd.read_csv('mappings/industries.csv')\n",
85
+ "skills_map = pd.read_csv('mappings/skills.csv')\n",
86
+ "print(f\"✅ Mappings loaded\")\n",
87
+ "\n",
88
+ "print(f\"\\n📊 Base company columns: {companies_base.columns.tolist()}\")"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "markdown",
93
+ "metadata": {},
94
+ "source": [
95
+ "## 🔗 Step 3: Merge Company Data (Create Rich Entities)\n",
96
+ "\n",
97
+ "Aggregate multiple dimensions into single company profile."
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": null,
103
+ "metadata": {},
104
+ "outputs": [],
105
+ "source": [
106
+ "print(\"🔗 Merging company data...\\n\")\n",
107
+ "\n",
108
+ "# Aggregate industries per company (many-to-many)\n",
109
+ "company_industries_agg = company_industries.groupby('company_id')['industry_id'].apply(\n",
110
+ " lambda x: ', '.join(map(str, x.tolist()))\n",
111
+ ").reset_index()\n",
112
+ "company_industries_agg.columns = ['company_id', 'industries_list']\n",
113
+ "\n",
114
+ "print(f\"✅ Aggregated industries for {len(company_industries_agg):,} companies\")\n",
115
+ "\n",
116
+ "# Aggregate specialties per company\n",
117
+ "company_specialties_agg = company_specialties.groupby('company_id')['specialty'].apply(\n",
118
+ " lambda x: ' | '.join(x.tolist())\n",
119
+ ").reset_index()\n",
120
+ "company_specialties_agg.columns = ['company_id', 'specialties_list']\n",
121
+ "\n",
122
+ "print(f\"✅ Aggregated specialties for {len(company_specialties_agg):,} companies\")\n",
123
+ "\n",
124
+ "# Merge everything into companies_base\n",
125
+ "companies_full = companies_base.copy()\n",
126
+ "\n",
127
+ "# Merge industries\n",
128
+ "companies_full = companies_full.merge(\n",
129
+ " company_industries_agg, \n",
130
+ " on='company_id', \n",
131
+ " how='left'\n",
132
+ ")\n",
133
+ "\n",
134
+ "# Merge specialties\n",
135
+ "companies_full = companies_full.merge(\n",
136
+ " company_specialties_agg, \n",
137
+ " on='company_id', \n",
138
+ " how='left'\n",
139
+ ")\n",
140
+ "\n",
141
+ "# Merge employee counts\n",
142
+ "companies_full = companies_full.merge(\n",
143
+ " employee_counts, \n",
144
+ " on='company_id', \n",
145
+ " how='left'\n",
146
+ ")\n",
147
+ "\n",
148
+ "# Fill NaN\n",
149
+ "companies_full = companies_full.fillna('')\n",
150
+ "\n",
151
+ "print(f\"\\n✅ MERGED DATASET CREATED!\")\n",
152
+ "print(f\"📊 Final companies: {len(companies_full):,} rows × {len(companies_full.columns)} columns\")\n",
153
+ "print(f\"\\n📋 Columns: {companies_full.columns.tolist()}\")\n",
154
+ "\n",
155
+ "# Show sample\n",
156
+ "print(f\"\\n👀 Sample company:\")\n",
157
+ "companies_full.head(3)"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "markdown",
162
+ "metadata": {},
163
+ "source": [
164
+ "## 📂 Step 4: Load Candidates"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": null,
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": [
173
+ "# Load candidates\n",
174
+ "candidates = pd.read_csv('resume_data.csv')\n",
175
+ "candidates = candidates.fillna('')\n",
176
+ "\n",
177
+ "print(f\"✅ Loaded {len(candidates):,} candidates × {len(candidates.columns)} columns\")\n",
178
+ "print(f\"\\n📋 Candidate columns: {candidates.columns.tolist()[:10]}...\")\n",
179
+ "candidates.head(3)"
180
+ ]
181
+ },
182
+ {
183
+ "cell_type": "markdown",
184
+ "metadata": {},
185
+ "source": [
186
+ "## 📝 Step 5: Create Text Representations (ℝⁿ preparation)\n",
187
+ "\n",
188
+ "Transform structured data → unified text → embeddings → vectors ∈ ℝⁿ"
189
+ ]
190
+ },
191
+ {
192
+ "cell_type": "code",
193
+ "execution_count": null,
194
+ "metadata": {},
195
+ "outputs": [],
196
+ "source": [
197
+ "print(\"📝 Creating text representations...\\n\")\n",
198
+ "\n",
199
+ "# Candidate text\n",
200
+ "def make_candidate_text(row):\n",
201
+ " parts = []\n",
202
+ " \n",
203
+ " if row.get('skills'): \n",
204
+ " parts.append(f\"Skills: {row['skills']}\")\n",
205
+ " if row.get('career_objective'): \n",
206
+ " parts.append(f\"Objective: {row['career_objective']}\")\n",
207
+ " if row.get('educational_institution_name'): \n",
208
+ " parts.append(f\"Education: {row['educational_institution_name']}\")\n",
209
+ " if row.get('degree_names'): \n",
210
+ " parts.append(f\"Degree: {row['degree_names']}\")\n",
211
+ " if row.get('major_field_of_studies'): \n",
212
+ " parts.append(f\"Field: {row['major_field_of_studies']}\")\n",
213
+ " if row.get('positions'): \n",
214
+ " parts.append(f\"Experience: {row['positions']}\")\n",
215
+ " if row.get('responsibilities'): \n",
216
+ " parts.append(f\"Responsibilities: {str(row['responsibilities'])[:200]}\")\n",
217
+ " \n",
218
+ " return ' | '.join(parts) if parts else \"No info\"\n",
219
+ "\n",
220
+ "# Company text (from merged data!)\n",
221
+ "def make_company_text(row):\n",
222
+ " parts = []\n",
223
+ " \n",
224
+ " if row.get('name'): \n",
225
+ " parts.append(f\"Company: {row['name']}\")\n",
226
+ " if row.get('description'): \n",
227
+ " parts.append(f\"Description: {str(row['description'])[:300]}\")\n",
228
+ " if row.get('industries_list'): \n",
229
+ " parts.append(f\"Industries: {row['industries_list']}\")\n",
230
+ " if row.get('specialties_list'): \n",
231
+ " parts.append(f\"Specialties: {row['specialties_list']}\")\n",
232
+ " if row.get('employee_count'): \n",
233
+ " parts.append(f\"Size: {row['employee_count']} employees\")\n",
234
+ " if row.get('follower_count'): \n",
235
+ " parts.append(f\"Followers: {row['follower_count']}\")\n",
236
+ " if row.get('city') or row.get('state') or row.get('country'): \n",
237
+ " loc = f\"{row.get('city', '')}, {row.get('state', '')}, {row.get('country', '')}\"\n",
238
+ " parts.append(f\"Location: {loc}\")\n",
239
+ " \n",
240
+ " return ' | '.join(parts) if parts else \"No info\"\n",
241
+ "\n",
242
+ "# Apply\n",
243
+ "candidates['text'] = candidates.apply(make_candidate_text, axis=1)\n",
244
+ "companies_full['text'] = companies_full.apply(make_company_text, axis=1)\n",
245
+ "\n",
246
+ "print(\"✅ Text created!\")\n",
247
+ "print(f\"\\n📄 Sample candidate text:\\n{candidates['text'].iloc[0][:300]}...\")\n",
248
+ "print(f\"\\n📄 Sample company text:\\n{companies_full['text'].iloc[0][:300]}...\")"
249
+ ]
250
+ },
251
+ {
252
+ "cell_type": "markdown",
253
+ "metadata": {},
254
+ "source": [
255
+ "## 🧠 Step 6: Generate Embeddings (Transform to ℝⁿ)\n",
256
+ "\n",
257
+ "**CRITICAL:** This creates vectors in the SAME mathematical space!"
258
+ ]
259
+ },
260
+ {
261
+ "cell_type": "code",
262
+ "execution_count": null,
263
+ "metadata": {},
264
+ "outputs": [],
265
+ "source": [
266
+ "print(\"🧠 Loading embedding model...\")\n",
267
+ "model = SentenceTransformer('all-MiniLM-L6-v2') # Creates 384-dim vectors\n",
268
+ "\n",
269
+ "print(f\"✅ Model loaded! Embedding dimension: {model.get_sentence_embedding_dimension()}\")\n",
270
+ "print(f\"\\n🔄 Generating candidate vectors (this may take a few minutes)...\")\n",
271
+ "cand_vectors = model.encode(candidates['text'].tolist(), show_progress_bar=True)\n",
272
+ "\n",
273
+ "print(f\"\\n🔄 Generating company vectors (180K companies - this will take time!)...\")\n",
274
+ "comp_vectors = model.encode(companies_full['text'].tolist(), show_progress_bar=True, batch_size=64)\n",
275
+ "\n",
276
+ "print(f\"\\n✅ VECTORS CREATED!\")\n",
277
+ "print(f\"📊 Candidate vectors: {cand_vectors.shape}\")\n",
278
+ "print(f\"📊 Company vectors: {comp_vectors.shape}\")\n",
279
+ "print(f\"\\n🎯 Both live in ℝ^{model.get_sentence_embedding_dimension()} !\")"
280
+ ]
281
+ },
282
+ {
283
+ "cell_type": "markdown",
284
+ "metadata": {},
285
+ "source": [
286
+ "## 🎯 Step 7: Matching Engine (Cosine Similarity)"
287
+ ]
288
+ },
289
+ {
290
+ "cell_type": "code",
291
+ "execution_count": null,
292
+ "metadata": {},
293
+ "outputs": [],
294
+ "source": [
295
+ "def cosine_similarity(a, b):\n",
296
+ " \"\"\"Calculate cosine similarity between two vectors.\"\"\"\n",
297
+ " return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))\n",
298
+ "\n",
299
+ "def find_top_matches(candidate_idx, top_k=10):\n",
300
+ " \"\"\"\n",
301
+ " Find top K company matches for a candidate.\n",
302
+ " \n",
303
+ " Returns: List of (company_idx, similarity_score)\n",
304
+ " \"\"\"\n",
305
+ " cand_vec = cand_vectors[candidate_idx]\n",
306
+ " \n",
307
+ " # Calculate similarities with ALL 180K companies\n",
308
+ " scores = []\n",
309
+ " for i, comp_vec in enumerate(comp_vectors):\n",
310
+ " score = cosine_similarity(cand_vec, comp_vec)\n",
311
+ " scores.append((i, score))\n",
312
+ " \n",
313
+ " # Sort by score (descending)\n",
314
+ " scores.sort(key=lambda x: x[1], reverse=True)\n",
315
+ " \n",
316
+ " return scores[:top_k]\n",
317
+ "\n",
318
+ "print(\"✅ Matching engine ready!\")\n",
319
+ "print(f\"📊 Ready to match {len(candidates):,} candidates with {len(companies_full):,} companies!\")"
320
+ ]
321
+ },
322
+ {
323
+ "cell_type": "markdown",
324
+ "metadata": {},
325
+ "source": [
326
+ "## 🔍 Step 8: Test - Find Matches for Candidate #0"
327
+ ]
328
+ },
329
+ {
330
+ "cell_type": "code",
331
+ "execution_count": null,
332
+ "metadata": {},
333
+ "outputs": [],
334
+ "source": [
335
+ "print(\"🔍 Finding top 10 matches for Candidate #0...\\n\")\n",
336
+ "\n",
337
+ "matches = find_top_matches(0, top_k=10)\n",
338
+ "\n",
339
+ "print(\"🎯 Top 10 Company Matches:\\n\")\n",
340
+ "print(\"=\" * 80)\n",
341
+ "print(f\"{'Rank':<6} {'Score':<8} {'Company Name':<40} {'Industry'}\")\n",
342
+ "print(\"=\" * 80)\n",
343
+ "\n",
344
+ "for rank, (comp_idx, score) in enumerate(matches, 1):\n",
345
+ " company_name = companies_full.iloc[comp_idx].get('name', 'N/A')[:40]\n",
346
+ " industry = companies_full.iloc[comp_idx].get('industries_list', 'N/A')[:30]\n",
347
+ " print(f\"{rank:<6} {score:.4f} {company_name:<40} {industry}\")\n",
348
+ "\n",
349
+ "print(\"=\" * 80)"
350
+ ]
351
+ },
352
+ {
353
+ "cell_type": "markdown",
354
+ "metadata": {},
355
+ "source": [
356
+ "## 📊 Step 9: Visualize Match Distribution"
357
+ ]
358
+ },
359
+ {
360
+ "cell_type": "code",
361
+ "execution_count": null,
362
+ "metadata": {},
363
+ "outputs": [],
364
+ "source": [
365
+ "# Get scores for sample\n",
366
+ "all_scores = []\n",
367
+ "sample_size = min(100, len(candidates))\n",
368
+ "\n",
369
+ "print(f\"📊 Computing match scores for {sample_size} candidates...\")\n",
370
+ "\n",
371
+ "for i in range(sample_size):\n",
372
+ " if i % 20 == 0:\n",
373
+ " print(f\" Progress: {i}/{sample_size}\")\n",
374
+ " matches = find_top_matches(i, top_k=10)\n",
375
+ " for comp_idx, score in matches:\n",
376
+ " all_scores.append(score)\n",
377
+ "\n",
378
+ "# Plot\n",
379
+ "fig = px.histogram(\n",
380
+ " x=all_scores,\n",
381
+ " nbins=50,\n",
382
+ " title=f'Distribution of Match Scores ({len(candidates):,} candidates × {len(companies_full):,} companies)',\n",
383
+ " labels={'x': 'Cosine Similarity Score'}\n",
384
+ ")\n",
385
+ "fig.show()\n",
386
+ "\n",
387
+ "print(f\"\\n📊 Statistics:\")\n",
388
+ "print(f\" Mean: {np.mean(all_scores):.4f}\")\n",
389
+ "print(f\" Median: {np.median(all_scores):.4f}\")\n",
390
+ "print(f\" Std: {np.std(all_scores):.4f}\")\n",
391
+ "print(f\" Max: {np.max(all_scores):.4f}\")"
392
+ ]
393
+ },
394
+ {
395
+ "cell_type": "markdown",
396
+ "metadata": {},
397
+ "source": [
398
+ "## 💾 Step 10: Export Results"
399
+ ]
400
+ },
401
+ {
402
+ "cell_type": "code",
403
+ "execution_count": null,
404
+ "metadata": {},
405
+ "outputs": [],
406
+ "source": [
407
+ "# Generate matches for sample\n",
408
+ "results = []\n",
409
+ "export_sample = min(500, len(candidates)) # Export matches for 500 candidates\n",
410
+ "\n",
411
+ "print(f\"💾 Generating matches for {export_sample} candidates...\\n\")\n",
412
+ "\n",
413
+ "for i in range(export_sample):\n",
414
+ " if i % 50 == 0:\n",
415
+ " print(f\" Progress: {i}/{export_sample}\")\n",
416
+ " \n",
417
+ " matches = find_top_matches(i, top_k=10)\n",
418
+ " \n",
419
+ " for rank, (comp_idx, score) in enumerate(matches, 1):\n",
420
+ " results.append({\n",
421
+ " 'candidate_id': i,\n",
422
+ " 'company_id': companies_full.iloc[comp_idx].get('company_id'),\n",
423
+ " 'company_name': companies_full.iloc[comp_idx].get('name', 'N/A'),\n",
424
+ " 'rank': rank,\n",
425
+ " 'similarity_score': float(score),\n",
426
+ " 'industry': companies_full.iloc[comp_idx].get('industries_list', 'N/A')[:50]\n",
427
+ " })\n",
428
+ "\n",
429
+ "# Create DataFrame\n",
430
+ "results_df = pd.DataFrame(results)\n",
431
+ "results_df.to_csv('hrhub_matches.csv', index=False)\n",
432
+ "\n",
433
+ "print(f\"\\n✅ Exported {len(results_df):,} matches to hrhub_matches.csv\")\n",
434
+ "print(f\"\\n👀 Preview:\")\n",
435
+ "results_df.head(20)"
436
+ ]
437
+ },
438
+ {
439
+ "cell_type": "markdown",
440
+ "metadata": {},
441
+ "source": [
442
+ "## 🎉 DONE!\n",
443
+ "\n",
444
+ "### ✅ What you have:\n",
445
+ "- **9,544 candidates** as vectors ∈ ℝ³⁸⁴\n",
446
+ "- **180,000 companies** as vectors ∈ ℝ³⁸⁴\n",
447
+ "- Both in the SAME mathematical space!\n",
448
+ "- Cosine similarity matching\n",
449
+ "- Exported results\n",
450
+ "\n",
451
+ "### 🚀 Next steps:\n",
452
+ "1. Add LLM explanations (optional - needs API key)\n",
453
+ "2. Implement user weights for dimensions\n",
454
+ "3. Build UI/API on top"
455
+ ]
456
+ }
457
+ ],
458
+ "metadata": {
459
+ "kernelspec": {
460
+ "display_name": "Python 3",
461
+ "language": "python",
462
+ "name": "python3"
463
+ },
464
+ "language_info": {
465
+ "name": "python",
466
+ "version": "3.8.0"
467
+ }
468
+ },
469
+ "nbformat": 4,
470
+ "nbformat_minor": 4
471
+ }
data/notebooks/lib/bindings/utils.js ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function neighbourhoodHighlight(params) {
2
+ // console.log("in nieghbourhoodhighlight");
3
+ allNodes = nodes.get({ returnType: "Object" });
4
+ // originalNodes = JSON.parse(JSON.stringify(allNodes));
5
+ // if something is selected:
6
+ if (params.nodes.length > 0) {
7
+ highlightActive = true;
8
+ var i, j;
9
+ var selectedNode = params.nodes[0];
10
+ var degrees = 2;
11
+
12
+ // mark all nodes as hard to read.
13
+ for (let nodeId in allNodes) {
14
+ // nodeColors[nodeId] = allNodes[nodeId].color;
15
+ allNodes[nodeId].color = "rgba(200,200,200,0.5)";
16
+ if (allNodes[nodeId].hiddenLabel === undefined) {
17
+ allNodes[nodeId].hiddenLabel = allNodes[nodeId].label;
18
+ allNodes[nodeId].label = undefined;
19
+ }
20
+ }
21
+ var connectedNodes = network.getConnectedNodes(selectedNode);
22
+ var allConnectedNodes = [];
23
+
24
+ // get the second degree nodes
25
+ for (i = 1; i < degrees; i++) {
26
+ for (j = 0; j < connectedNodes.length; j++) {
27
+ allConnectedNodes = allConnectedNodes.concat(
28
+ network.getConnectedNodes(connectedNodes[j])
29
+ );
30
+ }
31
+ }
32
+
33
+ // all second degree nodes get a different color and their label back
34
+ for (i = 0; i < allConnectedNodes.length; i++) {
35
+ // allNodes[allConnectedNodes[i]].color = "pink";
36
+ allNodes[allConnectedNodes[i]].color = "rgba(150,150,150,0.75)";
37
+ if (allNodes[allConnectedNodes[i]].hiddenLabel !== undefined) {
38
+ allNodes[allConnectedNodes[i]].label =
39
+ allNodes[allConnectedNodes[i]].hiddenLabel;
40
+ allNodes[allConnectedNodes[i]].hiddenLabel = undefined;
41
+ }
42
+ }
43
+
44
+ // all first degree nodes get their own color and their label back
45
+ for (i = 0; i < connectedNodes.length; i++) {
46
+ // allNodes[connectedNodes[i]].color = undefined;
47
+ allNodes[connectedNodes[i]].color = nodeColors[connectedNodes[i]];
48
+ if (allNodes[connectedNodes[i]].hiddenLabel !== undefined) {
49
+ allNodes[connectedNodes[i]].label =
50
+ allNodes[connectedNodes[i]].hiddenLabel;
51
+ allNodes[connectedNodes[i]].hiddenLabel = undefined;
52
+ }
53
+ }
54
+
55
+ // the main node gets its own color and its label back.
56
+ // allNodes[selectedNode].color = undefined;
57
+ allNodes[selectedNode].color = nodeColors[selectedNode];
58
+ if (allNodes[selectedNode].hiddenLabel !== undefined) {
59
+ allNodes[selectedNode].label = allNodes[selectedNode].hiddenLabel;
60
+ allNodes[selectedNode].hiddenLabel = undefined;
61
+ }
62
+ } else if (highlightActive === true) {
63
+ // console.log("highlightActive was true");
64
+ // reset all nodes
65
+ for (let nodeId in allNodes) {
66
+ // allNodes[nodeId].color = "purple";
67
+ allNodes[nodeId].color = nodeColors[nodeId];
68
+ // delete allNodes[nodeId].color;
69
+ if (allNodes[nodeId].hiddenLabel !== undefined) {
70
+ allNodes[nodeId].label = allNodes[nodeId].hiddenLabel;
71
+ allNodes[nodeId].hiddenLabel = undefined;
72
+ }
73
+ }
74
+ highlightActive = false;
75
+ }
76
+
77
+ // transform the object into an array
78
+ var updateArray = [];
79
+ if (params.nodes.length > 0) {
80
+ for (let nodeId in allNodes) {
81
+ if (allNodes.hasOwnProperty(nodeId)) {
82
+ // console.log(allNodes[nodeId]);
83
+ updateArray.push(allNodes[nodeId]);
84
+ }
85
+ }
86
+ nodes.update(updateArray);
87
+ } else {
88
+ // console.log("Nothing was selected");
89
+ for (let nodeId in allNodes) {
90
+ if (allNodes.hasOwnProperty(nodeId)) {
91
+ // console.log(allNodes[nodeId]);
92
+ // allNodes[nodeId].color = {};
93
+ updateArray.push(allNodes[nodeId]);
94
+ }
95
+ }
96
+ nodes.update(updateArray);
97
+ }
98
+ }
99
+
100
+ function filterHighlight(params) {
101
+ allNodes = nodes.get({ returnType: "Object" });
102
+ // if something is selected:
103
+ if (params.nodes.length > 0) {
104
+ filterActive = true;
105
+ let selectedNodes = params.nodes;
106
+
107
+ // hiding all nodes and saving the label
108
+ for (let nodeId in allNodes) {
109
+ allNodes[nodeId].hidden = true;
110
+ if (allNodes[nodeId].savedLabel === undefined) {
111
+ allNodes[nodeId].savedLabel = allNodes[nodeId].label;
112
+ allNodes[nodeId].label = undefined;
113
+ }
114
+ }
115
+
116
+ for (let i=0; i < selectedNodes.length; i++) {
117
+ allNodes[selectedNodes[i]].hidden = false;
118
+ if (allNodes[selectedNodes[i]].savedLabel !== undefined) {
119
+ allNodes[selectedNodes[i]].label = allNodes[selectedNodes[i]].savedLabel;
120
+ allNodes[selectedNodes[i]].savedLabel = undefined;
121
+ }
122
+ }
123
+
124
+ } else if (filterActive === true) {
125
+ // reset all nodes
126
+ for (let nodeId in allNodes) {
127
+ allNodes[nodeId].hidden = false;
128
+ if (allNodes[nodeId].savedLabel !== undefined) {
129
+ allNodes[nodeId].label = allNodes[nodeId].savedLabel;
130
+ allNodes[nodeId].savedLabel = undefined;
131
+ }
132
+ }
133
+ filterActive = false;
134
+ }
135
+
136
+ // transform the object into an array
137
+ var updateArray = [];
138
+ if (params.nodes.length > 0) {
139
+ for (let nodeId in allNodes) {
140
+ if (allNodes.hasOwnProperty(nodeId)) {
141
+ updateArray.push(allNodes[nodeId]);
142
+ }
143
+ }
144
+ nodes.update(updateArray);
145
+ } else {
146
+ for (let nodeId in allNodes) {
147
+ if (allNodes.hasOwnProperty(nodeId)) {
148
+ updateArray.push(allNodes[nodeId]);
149
+ }
150
+ }
151
+ nodes.update(updateArray);
152
+ }
153
+ }
154
+
155
+ function selectNode(nodes) {
156
+ network.selectNodes(nodes);
157
+ neighbourhoodHighlight({ nodes: nodes });
158
+ return nodes;
159
+ }
160
+
161
+ function selectNodes(nodes) {
162
+ network.selectNodes(nodes);
163
+ filterHighlight({nodes: nodes});
164
+ return nodes;
165
+ }
166
+
167
+ function highlightFilter(filter) {
168
+ let selectedNodes = []
169
+ let selectedProp = filter['property']
170
+ if (filter['item'] === 'node') {
171
+ let allNodes = nodes.get({ returnType: "Object" });
172
+ for (let nodeId in allNodes) {
173
+ if (allNodes[nodeId][selectedProp] && filter['value'].includes((allNodes[nodeId][selectedProp]).toString())) {
174
+ selectedNodes.push(nodeId)
175
+ }
176
+ }
177
+ }
178
+ else if (filter['item'] === 'edge'){
179
+ let allEdges = edges.get({returnType: 'object'});
180
+ // check if the selected property exists for selected edge and select the nodes connected to the edge
181
+ for (let edge in allEdges) {
182
+ if (allEdges[edge][selectedProp] && filter['value'].includes((allEdges[edge][selectedProp]).toString())) {
183
+ selectedNodes.push(allEdges[edge]['from'])
184
+ selectedNodes.push(allEdges[edge]['to'])
185
+ }
186
+ }
187
+ }
188
+ selectNodes(selectedNodes)
189
+ }
data/notebooks/lib/tom-select/tom-select.complete.min.js ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Tom Select v2.0.0-rc.4
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ */
5
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TomSelect=t()}(this,(function(){"use strict"
6
+ function e(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class t{constructor(){this._events={}}on(t,i){e(t,(e=>{this._events[e]=this._events[e]||[],this._events[e].push(i)}))}off(t,i){var s=arguments.length
7
+ 0!==s?e(t,(e=>{if(1===s)return delete this._events[e]
8
+ e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(i),1)})):this._events={}}trigger(t,...i){var s=this
9
+ e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i
10
+ const s="[̀-ͯ·ʾ]",n=new RegExp(s,"g")
11
+ var o
12
+ const r={"æ":"ae","ⱥ":"a","ø":"o"},l=new RegExp(Object.keys(r).join("|"),"g"),a=[[67,67],[160,160],[192,438],[452,652],[961,961],[1019,1019],[1083,1083],[1281,1289],[1984,1984],[5095,5095],[7429,7441],[7545,7549],[7680,7935],[8580,8580],[9398,9449],[11360,11391],[42792,42793],[42802,42851],[42873,42897],[42912,42922],[64256,64260],[65313,65338],[65345,65370]],c=e=>e.normalize("NFKD").replace(n,"").toLowerCase().replace(l,(function(e){return r[e]})),d=(e,t="|")=>{if(1==e.length)return e[0]
13
+ var i=1
14
+ return e.forEach((e=>{i=Math.max(i,e.length)})),1==i?"["+e.join("")+"]":"(?:"+e.join(t)+")"},p=e=>{if(1===e.length)return[[e]]
15
+ var t=[]
16
+ return p(e.substring(1)).forEach((function(i){var s=i.slice(0)
17
+ s[0]=e.charAt(0)+s[0],t.push(s),(s=i.slice(0)).unshift(e.charAt(0)),t.push(s)})),t},u=e=>{void 0===o&&(o=(()=>{var e={}
18
+ a.forEach((t=>{for(let s=t[0];s<=t[1];s++){let t=String.fromCharCode(s),n=c(t)
19
+ if(n!=t.toLowerCase()){n in e||(e[n]=[n])
20
+ var i=new RegExp(d(e[n]),"iu")
21
+ t.match(i)||e[n].push(t)}}}))
22
+ var t=Object.keys(e)
23
+ t=t.sort(((e,t)=>t.length-e.length)),i=new RegExp("("+d(t)+"[̀-ͯ·ʾ]*)","g")
24
+ var s={}
25
+ return t.sort(((e,t)=>e.length-t.length)).forEach((t=>{var i=p(t).map((t=>(t=t.map((t=>e.hasOwnProperty(t)?d(e[t]):t)),d(t,""))))
26
+ s[t]=d(i)})),s})())
27
+ return e.normalize("NFKD").toLowerCase().split(i).map((e=>{if(""==e)return""
28
+ const t=c(e)
29
+ if(o.hasOwnProperty(t))return o[t]
30
+ const i=e.normalize("NFC")
31
+ return i!=e?d([e,i]):e})).join("")},h=(e,t)=>{if(e)return e[t]},g=(e,t)=>{if(e){for(var i,s=t.split(".");(i=s.shift())&&(e=e[i]););return e}},f=(e,t,i)=>{var s,n
32
+ return e?-1===(n=(e+="").search(t.regex))?0:(s=t.string.length/e.length,0===n&&(s+=.5),s*i):0},v=e=>(e+"").replace(/([\$\(-\+\.\?\[-\^\{-\}])/g,"\\$1"),m=(e,t)=>{var i=e[t]
33
+ if("function"==typeof i)return i
34
+ i&&!Array.isArray(i)&&(e[t]=[i])},y=(e,t)=>{if(Array.isArray(e))e.forEach(t)
35
+ else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},O=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=c(e+"").toLowerCase())>(t=c(t+"").toLowerCase())?1:t>e?-1:0
36
+ class b{constructor(e,t){this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
37
+ const s=[],n=e.split(/\s+/)
38
+ var o
39
+ return i&&(o=new RegExp("^("+Object.keys(i).map(v).join("|")+"):(.*)$")),n.forEach((e=>{let i,n=null,r=null
40
+ o&&(i=e.match(o))&&(n=i[1],e=i[2]),e.length>0&&(r=v(e),this.settings.diacritics&&(r=u(r)),t&&(r="\\b"+r)),s.push({string:e,regex:r?new RegExp(r,"iu"):null,field:n})})),s}getScoreFunction(e,t){var i=this.prepareSearch(e,t)
41
+ return this._getScoreFunction(i)}_getScoreFunction(e){const t=e.tokens,i=t.length
42
+ if(!i)return function(){return 0}
43
+ const s=e.options.fields,n=e.weights,o=s.length,r=e.getAttrFn
44
+ if(!o)return function(){return 1}
45
+ const l=1===o?function(e,t){const i=s[0].field
46
+ return f(r(t,i),e,n[i])}:function(e,t){var i=0
47
+ if(e.field){const s=r(t,e.field)
48
+ !e.regex&&s?i+=1/o:i+=f(s,e,1)}else y(n,((s,n)=>{i+=f(r(t,n),e,s)}))
49
+ return i/o}
50
+ return 1===i?function(e){return l(t[0],e)}:"and"===e.options.conjunction?function(e){for(var s,n=0,o=0;n<i;n++){if((s=l(t[n],e))<=0)return 0
51
+ o+=s}return o/i}:function(e){var s=0
52
+ return y(t,(t=>{s+=l(t,e)})),s/i}}getSortFunction(e,t){var i=this.prepareSearch(e,t)
53
+ return this._getSortFunction(i)}_getSortFunction(e){var t,i,s
54
+ const n=this,o=e.options,r=!e.query&&o.sort_empty?o.sort_empty:o.sort,l=[],a=[]
55
+ if("function"==typeof r)return r.bind(this)
56
+ const c=function(t,i){return"$score"===t?i.score:e.getAttrFn(n.items[i.id],t)}
57
+ if(r)for(t=0,i=r.length;t<i;t++)(e.query||"$score"!==r[t].field)&&l.push(r[t])
58
+ if(e.query){for(s=!0,t=0,i=l.length;t<i;t++)if("$score"===l[t].field){s=!1
59
+ break}s&&l.unshift({field:"$score",direction:"desc"})}else for(t=0,i=l.length;t<i;t++)if("$score"===l[t].field){l.splice(t,1)
60
+ break}for(t=0,i=l.length;t<i;t++)a.push("desc"===l[t].direction?-1:1)
61
+ const d=l.length
62
+ if(d){if(1===d){const e=l[0].field,t=a[0]
63
+ return function(i,s){return t*O(c(e,i),c(e,s))}}return function(e,t){var i,s,n
64
+ for(i=0;i<d;i++)if(n=l[i].field,s=a[i]*O(c(n,e),c(n,t)))return s
65
+ return 0}}return null}prepareSearch(e,t){const i={}
66
+ var s=Object.assign({},t)
67
+ if(m(s,"sort"),m(s,"sort_empty"),s.fields){m(s,"fields")
68
+ const e=[]
69
+ s.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),i[t.field]="weight"in t?t.weight:1})),s.fields=e}return{options:s,query:e.toLowerCase().trim(),tokens:this.tokenize(e,s.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:s.nesting?g:h}}search(e,t){var i,s,n=this
70
+ s=this.prepareSearch(e,t),t=s.options,e=s.query
71
+ const o=t.score||n._getScoreFunction(s)
72
+ e.length?y(n.items,((e,n)=>{i=o(e),(!1===t.filter||i>0)&&s.items.push({score:i,id:n})})):y(n.items,((e,t)=>{s.items.push({score:1,id:t})}))
73
+ const r=n._getSortFunction(s)
74
+ return r&&s.items.sort(r),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const w=e=>{if(e.jquery)return e[0]
75
+ if(e instanceof HTMLElement)return e
76
+ if(e.indexOf("<")>-1){let t=document.createElement("div")
77
+ return t.innerHTML=e.trim(),t.firstChild}return document.querySelector(e)},_=(e,t)=>{var i=document.createEvent("HTMLEvents")
78
+ i.initEvent(t,!0,!1),e.dispatchEvent(i)},I=(e,t)=>{Object.assign(e.style,t)},C=(e,...t)=>{var i=A(t);(e=x(e)).map((e=>{i.map((t=>{e.classList.add(t)}))}))},S=(e,...t)=>{var i=A(t);(e=x(e)).map((e=>{i.map((t=>{e.classList.remove(t)}))}))},A=e=>{var t=[]
79
+ return y(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},x=e=>(Array.isArray(e)||(e=[e]),e),k=(e,t,i)=>{if(!i||i.contains(e))for(;e&&e.matches;){if(e.matches(t))return e
80
+ e=e.parentNode}},F=(e,t=0)=>t>0?e[e.length-1]:e[0],L=(e,t)=>{if(!e)return-1
81
+ t=t||e.nodeName
82
+ for(var i=0;e=e.previousElementSibling;)e.matches(t)&&i++
83
+ return i},P=(e,t)=>{y(t,((t,i)=>{null==t?e.removeAttribute(i):e.setAttribute(i,""+t)}))},E=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},T=(e,t)=>{if(null===t)return
84
+ if("string"==typeof t){if(!t.length)return
85
+ t=new RegExp(t,"i")}const i=e=>3===e.nodeType?(e=>{var i=e.data.match(t)
86
+ if(i&&e.data.length>0){var s=document.createElement("span")
87
+ s.className="highlight"
88
+ var n=e.splitText(i.index)
89
+ n.splitText(i[0].length)
90
+ var o=n.cloneNode(!0)
91
+ return s.appendChild(o),E(n,s),1}return 0})(e):((e=>{if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&("highlight"!==e.className||"SPAN"!==e.tagName))for(var t=0;t<e.childNodes.length;++t)t+=i(e.childNodes[t])})(e),0)
92
+ i(e)},V="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey"
93
+ var j={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}}
94
+ const q=e=>null==e?null:D(e),D=e=>"boolean"==typeof e?e?"1":"0":e+"",N=e=>(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),z=(e,t)=>{var i
95
+ return function(s,n){var o=this
96
+ i&&(o.loading=Math.max(o.loading-1,0),clearTimeout(i)),i=setTimeout((function(){i=null,o.loadedSearches[s]=!0,e.call(o,s,n)}),t)}},R=(e,t,i)=>{var s,n=e.trigger,o={}
97
+ for(s in e.trigger=function(){var i=arguments[0]
98
+ if(-1===t.indexOf(i))return n.apply(e,arguments)
99
+ o[i]=arguments},i.apply(e,[]),e.trigger=n,o)n.apply(e,o[s])},H=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},B=(e,t,i,s)=>{e.addEventListener(t,i,s)},K=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),M=(e,t)=>{const i=e.getAttribute("id")
100
+ return i||(e.setAttribute("id",t),t)},Q=e=>e.replace(/[\\"']/g,"\\$&"),G=(e,t)=>{t&&e.append(t)}
101
+ function U(e,t){var i=Object.assign({},j,t),s=i.dataAttr,n=i.labelField,o=i.valueField,r=i.disabledField,l=i.optgroupField,a=i.optgroupLabelField,c=i.optgroupValueField,d=e.tagName.toLowerCase(),p=e.getAttribute("placeholder")||e.getAttribute("data-placeholder")
102
+ if(!p&&!i.allowEmptyOption){let t=e.querySelector('option[value=""]')
103
+ t&&(p=t.textContent)}var u,h,g,f,v,m,O={placeholder:p,options:[],optgroups:[],items:[],maxItems:null}
104
+ return"select"===d?(h=O.options,g={},f=1,v=e=>{var t=Object.assign({},e.dataset),i=s&&t[s]
105
+ return"string"==typeof i&&i.length&&(t=Object.assign(t,JSON.parse(i))),t},m=(e,t)=>{var s=q(e.value)
106
+ if(null!=s&&(s||i.allowEmptyOption)){if(g.hasOwnProperty(s)){if(t){var a=g[s][l]
107
+ a?Array.isArray(a)?a.push(t):g[s][l]=[a,t]:g[s][l]=t}}else{var c=v(e)
108
+ c[n]=c[n]||e.textContent,c[o]=c[o]||s,c[r]=c[r]||e.disabled,c[l]=c[l]||t,c.$option=e,g[s]=c,h.push(c)}e.selected&&O.items.push(s)}},O.maxItems=e.hasAttribute("multiple")?null:1,y(e.children,(e=>{var t,i,s
109
+ "optgroup"===(u=e.tagName.toLowerCase())?((s=v(t=e))[a]=s[a]||t.getAttribute("label")||"",s[c]=s[c]||f++,s[r]=s[r]||t.disabled,O.optgroups.push(s),i=s[c],y(t.children,(e=>{m(e,i)}))):"option"===u&&m(e)}))):(()=>{const t=e.getAttribute(s)
110
+ if(t)O.options=JSON.parse(t),y(O.options,(e=>{O.items.push(e[o])}))
111
+ else{var r=e.value.trim()||""
112
+ if(!i.allowEmptyOption&&!r.length)return
113
+ const t=r.split(i.delimiter)
114
+ y(t,(e=>{const t={}
115
+ t[n]=e,t[o]=e,O.options.push(t)})),O.items=t}})(),Object.assign({},j,O,t)}var W=0
116
+ class J extends(function(e){return e.plugins={},class extends e{constructor(...e){super(...e),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,i){e.plugins[t]={name:t,fn:i}}initializePlugins(e){var t,i
117
+ const s=this,n=[]
118
+ if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?n.push(e):(s.plugins.settings[e.name]=e.options,n.push(e.name))}))
119
+ else if(e)for(t in e)e.hasOwnProperty(t)&&(s.plugins.settings[t]=e[t],n.push(t))
120
+ for(;i=n.shift();)s.require(i)}loadPlugin(t){var i=this,s=i.plugins,n=e.plugins[t]
121
+ if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')
122
+ s.requested[t]=!0,s.loaded[t]=n.fn.apply(i,[i.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,i=t.plugins
123
+ if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")')
124
+ t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
125
+ super(),this.order=0,this.isOpen=!1,this.isDisabled=!1,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.hasOptions=!1,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],W++
126
+ var s=w(e)
127
+ if(s.tomselect)throw new Error("Tom Select already initialized on this element")
128
+ s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction")
129
+ const n=U(s,t)
130
+ this.settings=n,this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=M(s,"tomselect-"+W),this.isRequired=s.required,this.sifter=new b(this.options,{diacritics:n.diacritics}),n.mode=n.mode||(1===n.maxItems?"single":"multi"),"boolean"!=typeof n.hideSelected&&(n.hideSelected="multi"===n.mode),"boolean"!=typeof n.hidePlaceholder&&(n.hidePlaceholder="multi"!==n.mode)
131
+ var o=n.createFilter
132
+ "function"!=typeof o&&("string"==typeof o&&(o=new RegExp(o)),o instanceof RegExp?n.createFilter=e=>o.test(e):n.createFilter=()=>!0),this.initializePlugins(n.plugins),this.setupCallbacks(),this.setupTemplates()
133
+ const r=w("<div>"),l=w("<div>"),a=this._render("dropdown"),c=w('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",p=n.mode
134
+ var u
135
+ if(C(r,n.wrapperClass,d,p),C(l,n.controlClass),G(r,l),C(a,n.dropdownClass,p),n.copyClassesToDropdown&&C(a,d),C(c,n.dropdownContentClass),G(a,c),w(n.dropdownParent||r).appendChild(a),n.hasOwnProperty("controlInput"))n.controlInput?(u=w(n.controlInput),this.focus_node=u):(u=w("<input/>"),this.focus_node=l)
136
+ else{u=w('<input type="text" autocomplete="off" size="1" />')
137
+ y(["autocorrect","autocapitalize","autocomplete"],(e=>{s.getAttribute(e)&&P(u,{[e]:s.getAttribute(e)})})),u.tabIndex=-1,l.appendChild(u),this.focus_node=u}this.wrapper=r,this.dropdown=a,this.dropdown_content=c,this.control=l,this.control_input=u,this.setup()}setup(){const e=this,t=e.settings,i=e.control_input,s=e.dropdown,n=e.dropdown_content,o=e.wrapper,r=e.control,l=e.input,a=e.focus_node,c={passive:!0},d=e.inputId+"-ts-dropdown"
138
+ P(n,{id:d}),P(a,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d})
139
+ const p=M(a,e.inputId+"-ts-control"),u="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",h=document.querySelector(u),g=e.focus.bind(e)
140
+ if(h){B(h,"click",g),P(h,{for:p})
141
+ const t=M(h,e.inputId+"-ts-label")
142
+ P(a,{"aria-labelledby":t}),P(n,{"aria-labelledby":t})}if(o.style.width=l.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-")
143
+ C([o,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&P(l,{multiple:"multiple"}),e.settings.placeholder&&P(i,{placeholder:t.placeholder}),!e.settings.splitOn&&e.settings.delimiter&&(e.settings.splitOn=new RegExp("\\s*"+v(e.settings.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=z(t.load,t.loadThrottle)),e.control_input.type=l.type,B(s,"click",(t=>{const i=k(t.target,"[data-selectable]")
144
+ i&&(e.onOptionSelect(t,i),H(t,!0))})),B(r,"click",(t=>{var s=k(t.target,"[data-ts-item]",r)
145
+ s&&e.onItemSelect(t,s)?H(t,!0):""==i.value&&(e.onClick(),H(t,!0))})),B(i,"mousedown",(e=>{""!==i.value&&e.stopPropagation()})),B(a,"keydown",(t=>e.onKeyDown(t))),B(i,"keypress",(t=>e.onKeyPress(t))),B(i,"input",(t=>e.onInput(t))),B(a,"resize",(()=>e.positionDropdown()),c),B(a,"blur",(t=>e.onBlur(t))),B(a,"focus",(t=>e.onFocus(t))),B(a,"paste",(t=>e.onPaste(t)))
146
+ const f=t=>{const i=t.composedPath()[0]
147
+ if(!o.contains(i)&&!s.contains(i))return e.isFocused&&e.blur(),void e.inputState()
148
+ H(t,!0)}
149
+ var m=()=>{e.isOpen&&e.positionDropdown()}
150
+ B(document,"mousedown",f),B(window,"scroll",m,c),B(window,"resize",m,c),this._destroy=()=>{document.removeEventListener("mousedown",f),window.removeEventListener("sroll",m),window.removeEventListener("resize",m),h&&h.removeEventListener("click",g)},this.revertSettings={innerHTML:l.innerHTML,tabIndex:l.tabIndex},l.tabIndex=-1,l.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,B(l,"invalid",(t=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,l.disabled?e.disable():e.enable(),e.on("change",this.onChange),C(l,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),y(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,i=e.settings.optgroupLabelField,s={optgroup:e=>{let t=document.createElement("div")
151
+ return t.className="optgroup",t.appendChild(e.options),t},optgroup_header:(e,t)=>'<div class="optgroup-header">'+t(e[i])+"</div>",option:(e,i)=>"<div>"+i(e[t])+"</div>",item:(e,i)=>"<div>"+i(e[t])+"</div>",option_create:(e,t)=>'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>",no_results:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"}
152
+ e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){var e,t,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"}
153
+ for(e in i)(t=this.settings[i[e]])&&this.on(e,t)}sync(e=!0){const t=this,i=e?U(t.input,{delimiter:t.settings.delimiter}):t.settings
154
+ t.setupOptions(i.options,i.optgroups),t.setValue(i.items,!0),t.lastQuery=null}onClick(){var e=this
155
+ if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus()
156
+ e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){_(this.input,"input"),_(this.input,"change")}onPaste(e){var t=this
157
+ t.isFull()||t.isInputHidden||t.isLocked?H(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue()
158
+ if(e.match(t.settings.splitOn)){var i=e.trim().split(t.settings.splitOn)
159
+ y(i,(e=>{t.createItem(e)}))}}),0)}onKeyPress(e){var t=this
160
+ if(!t.isLocked){var i=String.fromCharCode(e.keyCode||e.which)
161
+ return t.settings.create&&"multi"===t.settings.mode&&i===t.settings.delimiter?(t.createItem(),void H(e)):void 0}H(e)}onKeyDown(e){var t=this
162
+ if(t.isLocked)9!==e.keyCode&&H(e)
163
+ else{switch(e.keyCode){case 65:if(K(V,e))return H(e),void t.selectAll()
164
+ break
165
+ case 27:return t.isOpen&&(H(e,!0),t.close()),void t.clearActiveItems()
166
+ case 40:if(!t.isOpen&&t.hasOptions)t.open()
167
+ else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1)
168
+ e&&t.setActiveOption(e)}return void H(e)
169
+ case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1)
170
+ e&&t.setActiveOption(e)}return void H(e)
171
+ case 13:return void(t.isOpen&&t.activeOption?(t.onOptionSelect(e,t.activeOption),H(e)):t.settings.create&&t.createItem()&&H(e))
172
+ case 37:return void t.advanceSelection(-1,e)
173
+ case 39:return void t.advanceSelection(1,e)
174
+ case 9:return void(t.settings.selectOnTab&&(t.isOpen&&t.activeOption&&(t.onOptionSelect(e,t.activeOption),H(e)),t.settings.create&&t.createItem()&&H(e)))
175
+ case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!K(V,e)&&H(e)}}onInput(e){var t=this
176
+ if(!t.isLocked){var i=t.inputValue()
177
+ t.lastValue!==i&&(t.lastValue=i,t.settings.shouldLoad.call(t,i)&&t.load(i),t.refreshOptions(),t.trigger("type",i))}}onFocus(e){var t=this,i=t.isFocused
178
+ if(t.isDisabled)return t.blur(),void H(e)
179
+ t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),i||t.trigger("focus"),t.activeItems.length||(t.showInput(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this
180
+ if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1
181
+ var i=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")}
182
+ t.settings.create&&t.settings.createOnBlur?t.createItem(null,!1,i):i()}}}onOptionSelect(e,t){var i,s=this
183
+ t&&(t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,!0,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(i=t.dataset.value)&&(s.lastQuery=null,s.addItem(i),s.settings.closeAfterSelect&&s.close(),!s.settings.hideSelected&&e.type&&/click/.test(e.type)&&s.setActiveOption(t))))}onItemSelect(e,t){var i=this
184
+ return!i.isLocked&&"multi"===i.settings.mode&&(H(e),i.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this
185
+ if(!t.canLoad(e))return
186
+ C(t.wrapper,t.settings.loadingClass),t.loading++
187
+ const i=t.loadCallback.bind(t)
188
+ t.settings.load.call(t,e,i)}loadCallback(e,t){const i=this
189
+ i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(e,t),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||S(i.wrapper,i.settings.loadingClass),i.trigger("load",e,t)}preload(){var e=this.wrapper.classList
190
+ e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input
191
+ t.value!==e&&(t.value=e,_(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){R(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var i,s,n,o,r,l,a=this
192
+ if("single"!==a.settings.mode){if(!e)return a.clearActiveItems(),void(a.isFocused&&a.showInput())
193
+ if("click"===(i=t&&t.type.toLowerCase())&&K("shiftKey",t)&&a.activeItems.length){for(l=a.getLastActive(),(n=Array.prototype.indexOf.call(a.control.children,l))>(o=Array.prototype.indexOf.call(a.control.children,e))&&(r=n,n=o,o=r),s=n;s<=o;s++)e=a.control.children[s],-1===a.activeItems.indexOf(e)&&a.setActiveItemClass(e)
194
+ H(t)}else"click"===i&&K(V,t)||"keydown"===i&&K("shiftKey",t)?e.classList.contains("active")?a.removeActiveItem(e):a.setActiveItemClass(e):(a.clearActiveItems(),a.setActiveItemClass(e))
195
+ a.hideInput(),a.isFocused||a.focus()}}setActiveItemClass(e){const t=this,i=t.control.querySelector(".last-active")
196
+ i&&S(i,"last-active"),C(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e)
197
+ this.activeItems.splice(t,1),S(e,"active")}clearActiveItems(){S(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,P(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),P(e,{"aria-selected":"true"}),C(e,"active"),this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
198
+ const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=e.offsetHeight,r=e.getBoundingClientRect().top-i.getBoundingClientRect().top+n
199
+ r+o>s+n?this.scroll(r-s+o,t):r<n&&this.scroll(r,t)}scroll(e,t){const i=this.dropdown_content
200
+ t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(S(this.activeOption,"active"),P(this.activeOption,{"aria-selected":null})),this.activeOption=null,P(this.focus_node,{"aria-activedescendant":null})}selectAll(){if("single"===this.settings.mode)return
201
+ const e=this.controlChildren()
202
+ e.length&&(this.hideInput(),this.close(),this.activeItems=e,C(e,"active"))}inputState(){var e=this
203
+ e.control.contains(e.control_input)&&(P(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&P(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
204
+ e.isDisabled||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField
205
+ return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,i,s,n=this,o=this.getSearchOptions()
206
+ if(n.settings.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new Error('Tom Select "score" setting must be a function that returns a function')
207
+ if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(o,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),n.settings.hideSelected)for(t=i.items.length-1;t>=0;t--){let e=q(i.items[t].id)
208
+ e&&-1!==n.items.indexOf(e)&&i.items.splice(t,1)}return i}refreshOptions(e=!0){var t,i,s,n,o,r,l,a,c,d,p
209
+ const u={},h=[]
210
+ var g,f=this,v=f.inputValue(),m=f.search(v),O=f.activeOption,b=f.settings.shouldOpen||!1,w=f.dropdown_content
211
+ for(O&&(c=O.dataset.value,d=O.closest("[data-group]")),n=m.items.length,"number"==typeof f.settings.maxOptions&&(n=Math.min(n,f.settings.maxOptions)),n>0&&(b=!0),t=0;t<n;t++){let e=m.items[t].id,n=f.options[e],l=f.getOption(e,!0)
212
+ for(f.settings.hideSelected||l.classList.toggle("selected",f.items.includes(e)),o=n[f.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++)o=r[i],f.optgroups.hasOwnProperty(o)||(o=""),u.hasOwnProperty(o)||(u[o]=document.createDocumentFragment(),h.push(o)),i>0&&(l=l.cloneNode(!0),P(l,{id:n.$id+"-clone-"+i,"aria-selected":null}),l.classList.add("ts-cloned"),S(l,"active")),c==e&&d&&d.dataset.group===o&&(O=l),u[o].appendChild(l)}this.settings.lockOptgroupOrder&&h.sort(((e,t)=>(f.optgroups[e]&&f.optgroups[e].$order||0)-(f.optgroups[t]&&f.optgroups[t].$order||0))),l=document.createDocumentFragment(),y(h,(e=>{if(f.optgroups.hasOwnProperty(e)&&u[e].children.length){let t=document.createDocumentFragment(),i=f.render("optgroup_header",f.optgroups[e])
213
+ G(t,i),G(t,u[e])
214
+ let s=f.render("optgroup",{group:f.optgroups[e],options:t})
215
+ G(l,s)}else G(l,u[e])})),w.innerHTML="",G(w,l),f.settings.highlight&&(g=w.querySelectorAll("span.highlight"),Array.prototype.forEach.call(g,(function(e){var t=e.parentNode
216
+ t.replaceChild(e.firstChild,e),t.normalize()})),m.query.length&&m.tokens.length&&y(m.tokens,(e=>{T(w,e.regex)})))
217
+ var _=e=>{let t=f.render(e,{input:v})
218
+ return t&&(b=!0,w.insertBefore(t,w.firstChild)),t}
219
+ if(f.loading?_("loading"):f.settings.shouldLoad.call(f,v)?0===m.items.length&&_("no_results"):_("not_loading"),(a=f.canCreate(v))&&(p=_("option_create")),f.hasOptions=m.items.length>0||a,b){if(m.items.length>0){if(!w.contains(O)&&"single"===f.settings.mode&&f.items.length&&(O=f.getOption(f.items[0])),!w.contains(O)){let e=0
220
+ p&&!f.settings.addPrecedence&&(e=1),O=f.selectable()[e]}}else p&&(O=p)
221
+ e&&!f.isOpen&&(f.open(),f.scrollToOption(O,"auto")),f.setActiveOption(O)}else f.clearActiveOption(),e&&f.isOpen&&f.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const i=this
222
+ if(Array.isArray(e))return i.addOptions(e,t),!1
223
+ const s=q(e[i.settings.valueField])
224
+ return null!==s&&!i.options.hasOwnProperty(s)&&(e.$order=e.$order||++i.order,e.$id=i.inputId+"-opt-"+e.$order,i.options[s]=e,i.lastQuery=null,t&&(i.userOptions[s]=t,i.trigger("option_add",s,e)),s)}addOptions(e,t=!1){y(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=q(e[this.settings.optgroupValueField])
225
+ return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var i
226
+ t[this.settings.optgroupValueField]=e,(i=this.registerOptionGroup(t))&&this.trigger("optgroup_add",i,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){const i=this
227
+ var s,n
228
+ const o=q(e),r=q(t[i.settings.valueField])
229
+ if(null===o)return
230
+ if(!i.options.hasOwnProperty(o))return
231
+ if("string"!=typeof r)throw new Error("Value must be set in option data")
232
+ const l=i.getOption(o),a=i.getItem(o)
233
+ if(t.$order=t.$order||i.options[o].$order,delete i.options[o],i.uncacheValue(r),i.options[r]=t,l){if(i.dropdown_content.contains(l)){const e=i._render("option",t)
234
+ E(l,e),i.activeOption===l&&i.setActiveOption(e)}l.remove()}a&&(-1!==(n=i.items.indexOf(o))&&i.items.splice(n,1,r),s=i._render("item",t),a.classList.contains("active")&&C(s,"active"),E(a,s)),i.lastQuery=null}removeOption(e,t){const i=this
235
+ e=D(e),i.uncacheValue(e),delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)}clearOptions(){this.loadedSearches={},this.userOptions={},this.clearCache()
236
+ var e={}
237
+ y(this.options,((t,i)=>{this.items.indexOf(i)>=0&&(e[i]=this.options[i])})),this.options=this.sifter.items=e,this.lastQuery=null,this.trigger("option_clear")}getOption(e,t=!1){const i=q(e)
238
+ if(null!==i&&this.options.hasOwnProperty(i)){const e=this.options[i]
239
+ if(e.$div)return e.$div
240
+ if(t)return this._render("option",e)}return null}getAdjacent(e,t,i="option"){var s
241
+ if(!e)return null
242
+ s="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]")
243
+ for(let i=0;i<s.length;i++)if(s[i]==e)return t>0?s[i+1]:s[i-1]
244
+ return null}getItem(e){if("object"==typeof e)return e
245
+ var t=q(e)
246
+ return null!==t?this.control.querySelector(`[data-value="${Q(t)}"]`):null}addItems(e,t){var i=this,s=Array.isArray(e)?e:[e]
247
+ for(let e=0,n=(s=s.filter((e=>-1===i.items.indexOf(e)))).length;e<n;e++)i.isPending=e<n-1,i.addItem(s[e],t)}addItem(e,t){R(this,t?[]:["change"],(()=>{var i,s
248
+ const n=this,o=n.settings.mode,r=q(e)
249
+ if((!r||-1===n.items.indexOf(r)||("single"===o&&n.close(),"single"!==o&&n.settings.duplicates))&&null!==r&&n.options.hasOwnProperty(r)&&("single"===o&&n.clear(t),"multi"!==o||!n.isFull())){if(i=n._render("item",n.options[r]),n.control.contains(i)&&(i=i.cloneNode(!0)),s=n.isFull(),n.items.splice(n.caretPos,0,r),n.insertAtCaret(i),n.isSetup){if(!n.isPending&&n.settings.hideSelected){let e=n.getOption(r),t=n.getAdjacent(e,1)
250
+ t&&n.setActiveOption(t)}n.isPending||n.refreshOptions(n.isFocused&&"single"!==o),0!=n.settings.closeAfterSelect&&n.isFull()?n.close():n.isPending||n.positionDropdown(),n.trigger("item_add",r,i),n.isPending||n.updateOriginalInput({silent:t})}(!n.isPending||!s&&n.isFull())&&(n.inputState(),n.refreshState())}}))}removeItem(e=null,t){const i=this
251
+ if(!(e=i.getItem(e)))return
252
+ var s,n
253
+ const o=e.dataset.value
254
+ s=L(e),e.remove(),e.classList.contains("active")&&(n=i.activeItems.indexOf(e),i.activeItems.splice(n,1),S(e,"active")),i.items.splice(s,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(o)&&i.removeOption(o,t),s<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:t}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",o,e)}createItem(e=null,t=!0,i=(()=>{})){var s,n=this,o=n.caretPos
255
+ if(e=e||n.inputValue(),!n.canCreate(e))return i(),!1
256
+ n.lock()
257
+ var r=!1,l=e=>{if(n.unlock(),!e||"object"!=typeof e)return i()
258
+ var s=q(e[n.settings.valueField])
259
+ if("string"!=typeof s)return i()
260
+ n.setTextboxValue(),n.addOption(e,!0),n.setCaret(o),n.addItem(s),n.refreshOptions(t&&"single"!==n.settings.mode),i(e),r=!0}
261
+ return s="function"==typeof n.settings.create?n.settings.create.call(this,e,l):{[n.settings.labelField]:e,[n.settings.valueField]:e},r||l(s),!0}refreshItems(){var e=this
262
+ e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this
263
+ e.refreshValidityState()
264
+ const t=e.isFull(),i=e.isLocked
265
+ e.wrapper.classList.toggle("rtl",e.rtl)
266
+ const s=e.wrapper.classList
267
+ var n
268
+ s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("required",e.isRequired),s.toggle("invalid",!e.isValid),s.toggle("locked",i),s.toggle("full",t),s.toggle("input-active",e.isFocused&&!e.isInputHidden),s.toggle("dropdown-active",e.isOpen),s.toggle("has-options",(n=e.options,0===Object.keys(n).length)),s.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this
269
+ e.input.checkValidity&&(e.isValid=e.input.checkValidity(),e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this
270
+ var i,s
271
+ const n=t.input.querySelector('option[value=""]')
272
+ if(t.is_select_tag){const e=[]
273
+ function o(i,s,o){return i||(i=w('<option value="'+N(s)+'">'+N(o)+"</option>")),i!=n&&t.input.append(i),e.push(i),i.selected=!0,i}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?o(n,"",""):t.items.forEach((n=>{if(i=t.options[n],s=i[t.settings.labelField]||"",e.includes(i.$option)){o(t.input.querySelector(`option[value="${Q(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
274
+ t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this
275
+ e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,P(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),I(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),I(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
276
+ e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.hideInput()),t.isOpen=!1,P(t.focus_node,{"aria-expanded":"false"}),I(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
277
+ I(this.dropdown,{width:t.width+"px",top:i+"px",left:s+"px"})}}clear(e){var t=this
278
+ if(t.items.length){var i=t.controlChildren()
279
+ y(i,(e=>{t.removeItem(e,!0)})),t.showInput(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,i=t.caretPos,s=t.control
280
+ s.insertBefore(e,s.children[i]),t.setCaret(i+1)}deleteSelection(e){var t,i,s,n,o,r=this
281
+ t=e&&8===e.keyCode?-1:1,i={start:(o=r.control_input).selectionStart||0,length:(o.selectionEnd||0)-(o.selectionStart||0)}
282
+ const l=[]
283
+ if(r.activeItems.length)n=F(r.activeItems,t),s=L(n),t>0&&s++,y(r.activeItems,(e=>l.push(e)))
284
+ else if((r.isFocused||"single"===r.settings.mode)&&r.items.length){const e=r.controlChildren()
285
+ t<0&&0===i.start&&0===i.length?l.push(e[r.caretPos-1]):t>0&&i.start===r.inputValue().length&&l.push(e[r.caretPos])}const a=l.map((e=>e.dataset.value))
286
+ if(!a.length||"function"==typeof r.settings.onDelete&&!1===r.settings.onDelete.call(r,a,e))return!1
287
+ for(H(e,!0),void 0!==s&&r.setCaret(s);l.length;)r.removeItem(l.pop())
288
+ return r.showInput(),r.positionDropdown(),r.refreshOptions(!1),!0}advanceSelection(e,t){var i,s,n=this
289
+ n.rtl&&(e*=-1),n.inputValue().length||(K(V,t)||K("shiftKey",t)?(s=(i=n.getLastActive(e))?i.classList.contains("active")?n.getAdjacent(i,e,"item"):i:e>0?n.control_input.nextElementSibling:n.control_input.previousElementSibling)&&(s.classList.contains("active")&&n.removeActiveItem(i),n.setActiveItemClass(s)):n.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active")
290
+ if(t)return t
291
+ var i=this.control.querySelectorAll(".active")
292
+ return i?F(i,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.close(),this.isLocked=!0,this.refreshState()}unlock(){this.isLocked=!1,this.refreshState()}disable(){var e=this
293
+ e.input.disabled=!0,e.control_input.disabled=!0,e.focus_node.tabIndex=-1,e.isDisabled=!0,e.lock()}enable(){var e=this
294
+ e.input.disabled=!1,e.control_input.disabled=!1,e.focus_node.tabIndex=e.tabIndex,e.isDisabled=!1,e.unlock()}destroy(){var e=this,t=e.revertSettings
295
+ e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,S(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){return"function"!=typeof this.settings.render[e]?null:this._render(e,t)}_render(e,t){var i,s,n=""
296
+ const o=this
297
+ return"option"!==e&&"item"!=e||(n=D(t[o.settings.valueField])),null==(s=o.settings.render[e].call(this,t,N))||(s=w(s),"option"===e||"option_create"===e?t[o.settings.disabledField]?P(s,{"aria-disabled":"true"}):P(s,{"data-selectable":""}):"optgroup"===e&&(i=t.group[o.settings.optgroupValueField],P(s,{"data-group":i}),t.group[o.settings.disabledField]&&P(s,{"data-disabled":""})),"option"!==e&&"item"!==e||(P(s,{"data-value":n}),"item"===e?(C(s,o.settings.itemClass),P(s,{"data-ts-item":""})):(C(s,o.settings.optionClass),P(s,{role:"option",id:t.$id}),o.options[n].$div=s))),s}clearCache(){y(this.options,((e,t)=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e)
298
+ t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,i){var s=this,n=s[t]
299
+ s[t]=function(){var t,o
300
+ return"after"===e&&(t=n.apply(s,arguments)),o=i.apply(s,arguments),"instead"===e?o:("before"===e&&(t=n.apply(s,arguments)),t)}}}return J.define("change_listener",(function(){B(this.input,"change",(()=>{this.sync()}))})),J.define("checkbox_options",(function(){var e=this,t=e.onOptionSelect
301
+ e.settings.hideSelected=!1
302
+ var i=function(e){setTimeout((()=>{var t=e.querySelector("input")
303
+ e.classList.contains("selected")?t.checked=!0:t.checked=!1}),1)}
304
+ e.hook("after","setupTemplates",(()=>{var t=e.settings.render.option
305
+ e.settings.render.option=(i,s)=>{var n=w(t.call(e,i,s)),o=document.createElement("input")
306
+ o.addEventListener("click",(function(e){H(e)})),o.type="checkbox"
307
+ const r=q(i[e.settings.valueField])
308
+ return r&&e.items.indexOf(r)>-1&&(o.checked=!0),n.prepend(o),n}})),e.on("item_remove",(t=>{var s=e.getOption(t)
309
+ s&&(s.classList.remove("selected"),i(s))})),e.hook("instead","onOptionSelect",((s,n)=>{if(n.classList.contains("selected"))return n.classList.remove("selected"),e.removeItem(n.dataset.value),e.refreshOptions(),void H(s,!0)
310
+ t.call(e,s,n),i(n)}))})),J.define("clear_button",(function(e){const t=this,i=Object.assign({className:"clear-button",title:"Clear All",html:e=>`<div class="${e.className}" title="${e.title}">&times;</div>`},e)
311
+ t.on("initialize",(()=>{var e=w(i.html(i))
312
+ e.addEventListener("click",(e=>{t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation()})),t.control.appendChild(e)}))})),J.define("drag_drop",(function(){var e=this
313
+ if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".')
314
+ if("multi"===e.settings.mode){var t=e.lock,i=e.unlock
315
+ e.hook("instead","lock",(()=>{var i=$(e.control).data("sortable")
316
+ return i&&i.disable(),t.call(e)})),e.hook("instead","unlock",(()=>{var t=$(e.control).data("sortable")
317
+ return t&&t.enable(),i.call(e)})),e.on("initialize",(()=>{var t=$(e.control).sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:e.isLocked,start:(e,i)=>{i.placeholder.css("width",i.helper.css("width")),t.css({overflow:"visible"})},stop:()=>{t.css({overflow:"hidden"})
318
+ var i=[]
319
+ t.children("[data-value]").each((function(){this.dataset.value&&i.push(this.dataset.value)})),e.setValue(i)}})}))}})),J.define("dropdown_header",(function(e){const t=this,i=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'<div class="'+e.headerClass+'"><div class="'+e.titleRowClass+'"><span class="'+e.labelClass+'">'+e.title+'</span><a class="'+e.closeClass+'">&times;</a></div></div>'},e)
320
+ t.on("initialize",(()=>{var e=w(i.html(i)),s=e.querySelector("."+i.closeClass)
321
+ s&&s.addEventListener("click",(e=>{H(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))})),J.define("caret_position",(function(){var e=this
322
+ e.hook("instead","setCaret",(t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach(((i,s)=>{s<t?e.control_input.insertAdjacentElement("beforebegin",i):e.control.appendChild(i)})):t=e.items.length,e.caretPos=t})),e.hook("instead","moveCaret",(t=>{if(!e.isFocused)return
323
+ const i=e.getLastActive(t)
324
+ if(i){const s=L(i)
325
+ e.setCaret(t>0?s+1:s),e.setActiveItem()}else e.setCaret(e.caretPos+t)}))})),J.define("dropdown_input",(function(){var e=this
326
+ e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,C(e.control_input,"dropdown-input")
327
+ const t=w('<div class="dropdown-input-wrap">')
328
+ t.append(e.control_input),e.dropdown.insertBefore(t,e.dropdown.firstChild)})),e.on("initialize",(()=>{e.control_input.addEventListener("keydown",(t=>{switch(t.keyCode){case 27:return e.isOpen&&(H(t,!0),e.close()),void e.clearActiveItems()
329
+ case 9:e.focus_node.tabIndex=-1}return e.onKeyDown.call(e,t)})),e.on("blur",(()=>{e.focus_node.tabIndex=e.isDisabled?-1:e.tabIndex})),e.on("dropdown_open",(()=>{e.control_input.focus()}))
330
+ const t=e.onBlur
331
+ e.hook("instead","onBlur",(i=>{if(!i||i.relatedTarget!=e.control_input)return t.call(e)})),B(e.control_input,"blur",(()=>e.onBlur())),e.hook("before","close",(()=>{e.isOpen&&e.focus_node.focus()}))}))})),J.define("input_autogrow",(function(){var e=this
332
+ e.on("initialize",(()=>{var t=document.createElement("span"),i=e.control_input
333
+ t.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",e.wrapper.appendChild(t)
334
+ for(const e of["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"])t.style[e]=i.style[e]
335
+ var s=()=>{e.items.length>0?(t.textContent=i.value,i.style.width=t.clientWidth+"px"):i.style.width=""}
336
+ s(),e.on("update item_add item_remove",s),B(i,"input",s),B(i,"keyup",s),B(i,"blur",s),B(i,"update",s)}))})),J.define("no_backspace_delete",(function(){var e=this,t=e.deleteSelection
337
+ this.hook("instead","deleteSelection",(i=>!!e.activeItems.length&&t.call(e,i)))})),J.define("no_active_items",(function(){this.hook("instead","setActiveItem",(()=>{})),this.hook("instead","selectAll",(()=>{}))})),J.define("optgroup_columns",(function(){var e=this,t=e.onKeyDown
338
+ e.hook("instead","onKeyDown",(i=>{var s,n,o,r
339
+ if(!e.isOpen||37!==i.keyCode&&39!==i.keyCode)return t.call(e,i)
340
+ r=k(e.activeOption,"[data-group]"),s=L(e.activeOption,"[data-selectable]"),r&&(r=37===i.keyCode?r.previousSibling:r.nextSibling)&&(n=(o=r.querySelectorAll("[data-selectable]"))[Math.min(o.length-1,s)])&&e.setActiveOption(n)}))})),J.define("remove_button",(function(e){const t=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},e)
341
+ var i=this
342
+ if(t.append){var s='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+N(t.title)+'">'+t.label+"</a>"
343
+ i.hook("after","setupTemplates",(()=>{var e=i.settings.render.item
344
+ i.settings.render.item=(t,n)=>{var o=w(e.call(i,t,n)),r=w(s)
345
+ return o.appendChild(r),B(r,"mousedown",(e=>{H(e,!0)})),B(r,"click",(e=>{if(H(e,!0),!i.isLocked){var t=o.dataset.value
346
+ i.removeItem(t),i.refreshOptions(!1)}})),o}}))}})),J.define("restore_on_backspace",(function(e){const t=this,i=Object.assign({text:e=>e[t.settings.labelField]},e)
347
+ t.on("item_remove",(function(e){if(""===t.control_input.value.trim()){var s=t.options[e]
348
+ s&&t.setTextboxValue(i.text.call(t,s))}}))})),J.define("virtual_scroll",(function(){const e=this,t=e.canLoad,i=e.clearActiveOption,s=e.loadCallback
349
+ var n,o={},r=!1
350
+ if(!e.settings.firstUrl)throw"virtual_scroll plugin requires a firstUrl() method"
351
+ function l(t){return!("number"==typeof e.settings.maxOptions&&n.children.length>=e.settings.maxOptions)&&!(!(t in o)||!o[t])}e.settings.sortField=[{field:"$order"},{field:"$score"}],e.setNextUrl=function(e,t){o[e]=t},e.getUrl=function(t){if(t in o){const e=o[t]
352
+ return o[t]=!1,e}return o={},e.settings.firstUrl(t)},e.hook("instead","clearActiveOption",(()=>{if(!r)return i.call(e)})),e.hook("instead","canLoad",(i=>i in o?l(i):t.call(e,i))),e.hook("instead","loadCallback",((t,i)=>{r||e.clearOptions(),s.call(e,t,i),r=!1})),e.hook("after","refreshOptions",(()=>{const t=e.lastValue
353
+ var i
354
+ l(t)?(i=e.render("loading_more",{query:t}))&&i.setAttribute("data-selectable",""):t in o&&!n.querySelector(".no-results")&&(i=e.render("no_more_results",{query:t})),i&&(C(i,e.settings.optionClass),n.append(i))})),e.on("initialize",(()=>{n=e.dropdown_content,e.settings.render=Object.assign({},{loading_more:function(){return'<div class="loading-more-results">Loading more results ... </div>'},no_more_results:function(){return'<div class="no-more-results">No more results</div>'}},e.settings.render),n.addEventListener("scroll",(function(){n.clientHeight/(n.scrollHeight-n.scrollTop)<.95||l(e.lastValue)&&(r||(r=!0,e.load.call(e,e.lastValue)))}))}))})),J}))
355
+ var tomSelect=function(e,t){return new TomSelect(e,t)}
356
+ //# sourceMappingURL=tom-select.complete.min.js.map
data/notebooks/lib/tom-select/tom-select.css ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * tom-select.css (v2.0.0-rc.4)
3
+ * Copyright (c) contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ */
15
+ .ts-wrapper.plugin-drag_drop.multi > .ts-control > div.ui-sortable-placeholder {
16
+ visibility: visible !important;
17
+ background: #f2f2f2 !important;
18
+ background: rgba(0, 0, 0, 0.06) !important;
19
+ border: 0 none !important;
20
+ box-shadow: inset 0 0 12px 4px #fff; }
21
+
22
+ .ts-wrapper.plugin-drag_drop .ui-sortable-placeholder::after {
23
+ content: '!';
24
+ visibility: hidden; }
25
+
26
+ .ts-wrapper.plugin-drag_drop .ui-sortable-helper {
27
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); }
28
+
29
+ .plugin-checkbox_options .option input {
30
+ margin-right: 0.5rem; }
31
+
32
+ .plugin-clear_button .ts-control {
33
+ padding-right: calc( 1em + (3 * 6px)) !important; }
34
+
35
+ .plugin-clear_button .clear-button {
36
+ opacity: 0;
37
+ position: absolute;
38
+ top: 8px;
39
+ right: calc(8px - 6px);
40
+ margin-right: 0 !important;
41
+ background: transparent !important;
42
+ transition: opacity 0.5s;
43
+ cursor: pointer; }
44
+
45
+ .plugin-clear_button.single .clear-button {
46
+ right: calc(8px - 6px + 2rem); }
47
+
48
+ .plugin-clear_button.focus.has-items .clear-button,
49
+ .plugin-clear_button:hover.has-items .clear-button {
50
+ opacity: 1; }
51
+
52
+ .ts-wrapper .dropdown-header {
53
+ position: relative;
54
+ padding: 10px 8px;
55
+ border-bottom: 1px solid #d0d0d0;
56
+ background: #f8f8f8;
57
+ border-radius: 3px 3px 0 0; }
58
+
59
+ .ts-wrapper .dropdown-header-close {
60
+ position: absolute;
61
+ right: 8px;
62
+ top: 50%;
63
+ color: #303030;
64
+ opacity: 0.4;
65
+ margin-top: -12px;
66
+ line-height: 20px;
67
+ font-size: 20px !important; }
68
+
69
+ .ts-wrapper .dropdown-header-close:hover {
70
+ color: black; }
71
+
72
+ .plugin-dropdown_input.focus.dropdown-active .ts-control {
73
+ box-shadow: none;
74
+ border: 1px solid #d0d0d0; }
75
+
76
+ .plugin-dropdown_input .dropdown-input {
77
+ border: 1px solid #d0d0d0;
78
+ border-width: 0 0 1px 0;
79
+ display: block;
80
+ padding: 8px 8px;
81
+ box-shadow: none;
82
+ width: 100%;
83
+ background: transparent; }
84
+
85
+ .ts-wrapper.plugin-input_autogrow.has-items .ts-control > input {
86
+ min-width: 0; }
87
+
88
+ .ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input {
89
+ flex: none;
90
+ min-width: 4px; }
91
+ .ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::-webkit-input-placeholder {
92
+ color: transparent; }
93
+ .ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::-ms-input-placeholder {
94
+ color: transparent; }
95
+ .ts-wrapper.plugin-input_autogrow.has-items.focus .ts-control > input::placeholder {
96
+ color: transparent; }
97
+
98
+ .ts-dropdown.plugin-optgroup_columns .ts-dropdown-content {
99
+ display: flex; }
100
+
101
+ .ts-dropdown.plugin-optgroup_columns .optgroup {
102
+ border-right: 1px solid #f2f2f2;
103
+ border-top: 0 none;
104
+ flex-grow: 1;
105
+ flex-basis: 0;
106
+ min-width: 0; }
107
+
108
+ .ts-dropdown.plugin-optgroup_columns .optgroup:last-child {
109
+ border-right: 0 none; }
110
+
111
+ .ts-dropdown.plugin-optgroup_columns .optgroup:before {
112
+ display: none; }
113
+
114
+ .ts-dropdown.plugin-optgroup_columns .optgroup-header {
115
+ border-top: 0 none; }
116
+
117
+ .ts-wrapper.plugin-remove_button .item {
118
+ display: inline-flex;
119
+ align-items: center;
120
+ padding-right: 0 !important; }
121
+
122
+ .ts-wrapper.plugin-remove_button .item .remove {
123
+ color: inherit;
124
+ text-decoration: none;
125
+ vertical-align: middle;
126
+ display: inline-block;
127
+ padding: 2px 6px;
128
+ border-left: 1px solid #d0d0d0;
129
+ border-radius: 0 2px 2px 0;
130
+ box-sizing: border-box;
131
+ margin-left: 6px; }
132
+
133
+ .ts-wrapper.plugin-remove_button .item .remove:hover {
134
+ background: rgba(0, 0, 0, 0.05); }
135
+
136
+ .ts-wrapper.plugin-remove_button .item.active .remove {
137
+ border-left-color: #cacaca; }
138
+
139
+ .ts-wrapper.plugin-remove_button.disabled .item .remove:hover {
140
+ background: none; }
141
+
142
+ .ts-wrapper.plugin-remove_button.disabled .item .remove {
143
+ border-left-color: white; }
144
+
145
+ .ts-wrapper.plugin-remove_button .remove-single {
146
+ position: absolute;
147
+ right: 0;
148
+ top: 0;
149
+ font-size: 23px; }
150
+
151
+ .ts-wrapper {
152
+ position: relative; }
153
+
154
+ .ts-dropdown,
155
+ .ts-control,
156
+ .ts-control input {
157
+ color: #303030;
158
+ font-family: inherit;
159
+ font-size: 13px;
160
+ line-height: 18px;
161
+ font-smoothing: inherit; }
162
+
163
+ .ts-control,
164
+ .ts-wrapper.single.input-active .ts-control {
165
+ background: #fff;
166
+ cursor: text; }
167
+
168
+ .ts-control {
169
+ border: 1px solid #d0d0d0;
170
+ padding: 8px 8px;
171
+ width: 100%;
172
+ overflow: hidden;
173
+ position: relative;
174
+ z-index: 1;
175
+ box-sizing: border-box;
176
+ box-shadow: none;
177
+ border-radius: 3px;
178
+ display: flex;
179
+ flex-wrap: wrap; }
180
+ .ts-wrapper.multi.has-items .ts-control {
181
+ padding: calc( 8px - 2px - 0) 8px calc( 8px - 2px - 3px - 0); }
182
+ .full .ts-control {
183
+ background-color: #fff; }
184
+ .disabled .ts-control,
185
+ .disabled .ts-control * {
186
+ cursor: default !important; }
187
+ .focus .ts-control {
188
+ box-shadow: none; }
189
+ .ts-control > * {
190
+ vertical-align: baseline;
191
+ display: inline-block; }
192
+ .ts-wrapper.multi .ts-control > div {
193
+ cursor: pointer;
194
+ margin: 0 3px 3px 0;
195
+ padding: 2px 6px;
196
+ background: #f2f2f2;
197
+ color: #303030;
198
+ border: 0 solid #d0d0d0; }
199
+ .ts-wrapper.multi .ts-control > div.active {
200
+ background: #e8e8e8;
201
+ color: #303030;
202
+ border: 0 solid #cacaca; }
203
+ .ts-wrapper.multi.disabled .ts-control > div, .ts-wrapper.multi.disabled .ts-control > div.active {
204
+ color: #7d7c7c;
205
+ background: white;
206
+ border: 0 solid white; }
207
+ .ts-control > input {
208
+ flex: 1 1 auto;
209
+ min-width: 7rem;
210
+ display: inline-block !important;
211
+ padding: 0 !important;
212
+ min-height: 0 !important;
213
+ max-height: none !important;
214
+ max-width: 100% !important;
215
+ margin: 0 !important;
216
+ text-indent: 0 !important;
217
+ border: 0 none !important;
218
+ background: none !important;
219
+ line-height: inherit !important;
220
+ -webkit-user-select: auto !important;
221
+ -moz-user-select: auto !important;
222
+ -ms-user-select: auto !important;
223
+ user-select: auto !important;
224
+ box-shadow: none !important; }
225
+ .ts-control > input::-ms-clear {
226
+ display: none; }
227
+ .ts-control > input:focus {
228
+ outline: none !important; }
229
+ .has-items .ts-control > input {
230
+ margin: 0 4px !important; }
231
+ .ts-control.rtl {
232
+ text-align: right; }
233
+ .ts-control.rtl.single .ts-control:after {
234
+ left: 15px;
235
+ right: auto; }
236
+ .ts-control.rtl .ts-control > input {
237
+ margin: 0 4px 0 -2px !important; }
238
+ .disabled .ts-control {
239
+ opacity: 0.5;
240
+ background-color: #fafafa; }
241
+ .input-hidden .ts-control > input {
242
+ opacity: 0;
243
+ position: absolute;
244
+ left: -10000px; }
245
+
246
+ .ts-dropdown {
247
+ position: absolute;
248
+ top: 100%;
249
+ left: 0;
250
+ width: 100%;
251
+ z-index: 10;
252
+ border: 1px solid #d0d0d0;
253
+ background: #fff;
254
+ margin: 0.25rem 0 0 0;
255
+ border-top: 0 none;
256
+ box-sizing: border-box;
257
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
258
+ border-radius: 0 0 3px 3px; }
259
+ .ts-dropdown [data-selectable] {
260
+ cursor: pointer;
261
+ overflow: hidden; }
262
+ .ts-dropdown [data-selectable] .highlight {
263
+ background: rgba(125, 168, 208, 0.2);
264
+ border-radius: 1px; }
265
+ .ts-dropdown .option,
266
+ .ts-dropdown .optgroup-header,
267
+ .ts-dropdown .no-results,
268
+ .ts-dropdown .create {
269
+ padding: 5px 8px; }
270
+ .ts-dropdown .option, .ts-dropdown [data-disabled], .ts-dropdown [data-disabled] [data-selectable].option {
271
+ cursor: inherit;
272
+ opacity: 0.5; }
273
+ .ts-dropdown [data-selectable].option {
274
+ opacity: 1;
275
+ cursor: pointer; }
276
+ .ts-dropdown .optgroup:first-child .optgroup-header {
277
+ border-top: 0 none; }
278
+ .ts-dropdown .optgroup-header {
279
+ color: #303030;
280
+ background: #fff;
281
+ cursor: default; }
282
+ .ts-dropdown .create:hover,
283
+ .ts-dropdown .option:hover,
284
+ .ts-dropdown .active {
285
+ background-color: #f5fafd;
286
+ color: #495c68; }
287
+ .ts-dropdown .create:hover.create,
288
+ .ts-dropdown .option:hover.create,
289
+ .ts-dropdown .active.create {
290
+ color: #495c68; }
291
+ .ts-dropdown .create {
292
+ color: rgba(48, 48, 48, 0.5); }
293
+ .ts-dropdown .spinner {
294
+ display: inline-block;
295
+ width: 30px;
296
+ height: 30px;
297
+ margin: 5px 8px; }
298
+ .ts-dropdown .spinner:after {
299
+ content: " ";
300
+ display: block;
301
+ width: 24px;
302
+ height: 24px;
303
+ margin: 3px;
304
+ border-radius: 50%;
305
+ border: 5px solid #d0d0d0;
306
+ border-color: #d0d0d0 transparent #d0d0d0 transparent;
307
+ animation: lds-dual-ring 1.2s linear infinite; }
308
+
309
+ @keyframes lds-dual-ring {
310
+ 0% {
311
+ transform: rotate(0deg); }
312
+ 100% {
313
+ transform: rotate(360deg); } }
314
+
315
+ .ts-dropdown-content {
316
+ overflow-y: auto;
317
+ overflow-x: hidden;
318
+ max-height: 200px;
319
+ overflow-scrolling: touch;
320
+ scroll-behavior: smooth; }
321
+
322
+ .ts-hidden-accessible {
323
+ border: 0 !important;
324
+ clip: rect(0 0 0 0) !important;
325
+ -webkit-clip-path: inset(50%) !important;
326
+ clip-path: inset(50%) !important;
327
+ height: 1px !important;
328
+ overflow: hidden !important;
329
+ padding: 0 !important;
330
+ position: absolute !important;
331
+ width: 1px !important;
332
+ white-space: nowrap !important; }
333
+
334
+ /*# sourceMappingURL=tom-select.css.map */
data/notebooks/lib/vis-9.1.2/vis-network.css ADDED
The diff for this file is too large to render. See raw diff
 
data/notebooks/lib/vis-9.1.2/vis-network.min.js ADDED
The diff for this file is too large to render. See raw diff
 
data/results/network_graph.html ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+
5
+ <script src="lib/bindings/utils.js"></script>
6
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/dist/vis-network.min.css" integrity="sha512-WgxfT5LWjfszlPHXRmBWHkV2eceiWTOBvrKCNbdgDYTHrT2AeLCGbF4sZlZw3UMN3WtL0tGUoIAKsu8mllg/XA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js" integrity="sha512-LnvoEWDFrqGHlHmDD2101OrLcbsfkrzoSpvtSQtxK3RMnRV0eOkhhBN2dXHKRrUU8p2DGRTk35n4O8nWSVe1mQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
8
+
9
+
10
+ <center>
11
+ <h1></h1>
12
+ </center>
13
+
14
+ <!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
15
+ <script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
16
+ <link
17
+ href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
18
+ rel="stylesheet"
19
+ integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
20
+ crossorigin="anonymous"
21
+ />
22
+ <script
23
+ src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
24
+ integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
25
+ crossorigin="anonymous"
26
+ ></script>
27
+
28
+
29
+ <center>
30
+ <h1></h1>
31
+ </center>
32
+ <style type="text/css">
33
+
34
+ #mynetwork {
35
+ width: 100%;
36
+ height: 800px;
37
+ background-color: #222;
38
+ border: 1px solid lightgray;
39
+ position: relative;
40
+ float: left;
41
+ }
42
+
43
+
44
+
45
+
46
+
47
+
48
+ </style>
49
+ </head>
50
+
51
+
52
+ <body>
53
+ <div class="card" style="width: 100%">
54
+
55
+
56
+ <div id="mynetwork" class="card-body"></div>
57
+ </div>
58
+
59
+
60
+
61
+
62
+ <script type="text/javascript">
63
+
64
+ // initialize global variables.
65
+ var edges;
66
+ var nodes;
67
+ var allNodes;
68
+ var allEdges;
69
+ var nodeColors;
70
+ var originalNodes;
71
+ var network;
72
+ var container;
73
+ var options, data;
74
+ var filter = {
75
+ item : '',
76
+ property : '',
77
+ value : []
78
+ };
79
+
80
+
81
+
82
+
83
+
84
+ // This method is responsible for drawing the graph, returns the drawn network
85
+ function drawGraph() {
86
+ var container = document.getElementById('mynetwork');
87
+
88
+
89
+
90
+ // parsing and collecting nodes and edges from the python
91
+ nodes = new vis.DataSet([{"color": "green", "font": {"color": "white"}, "id": "C0", "label": "Cand 0", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C1", "label": "Cand 1", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C2", "label": "Cand 2", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C3", "label": "Cand 3", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C4", "label": "Cand 4", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C5", "label": "Cand 5", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C6", "label": "Cand 6", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C7", "label": "Cand 7", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C8", "label": "Cand 8", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C9", "label": "Cand 9", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C10", "label": "Cand 10", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C11", "label": "Cand 11", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C12", "label": "Cand 12", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C13", "label": "Cand 13", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C14", "label": "Cand 14", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C15", "label": "Cand 15", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C16", "label": "Cand 16", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C17", "label": "Cand 17", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C18", "label": "Cand 18", "shape": "dot", "size": 25}, {"color": "green", "font": {"color": "white"}, "id": "C19", "label": "Cand 19", "shape": "dot", "size": 25}, {"color": "red", "font": {"color": "white"}, "id": "J9418", "label": "Anblicks", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J30989", "label": "iO Associates - US", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J9417", "label": "Anblicks", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J30990", "label": "iO Associates - US", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J9416", "label": "Anblicks", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J10140", "label": "Analytic Recruiting ", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J20529", "label": "Logikk", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J30163", "label": "Heliosz.AI", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J17134", "label": "BPO Recruit", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J28802", "label": "IntellectFaces, Inc", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J21756", "label": "maven", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J9454", "label": "Digital Prospectors", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J18817", "label": "Tekniforce", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J27159", "label": "Neva Recruiting", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J33214", "label": "micro1", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J26293", "label": "Ampstek", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J26294", "label": "Ampstek", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J26295", "label": "Ampstek", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J26296", "label": "Ampstek", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J27249", "label": "CivicMinds, Inc", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J23927", "label": "Swift Strategic Solu", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J237", "label": "National Security Ag", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J23926", "label": "Swift Strategic Solu", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J25745", "label": "AcctPositions", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J35525", "label": "Family Estate Planni", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J13170", "label": "Understanding Recrui", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J27248", "label": "CivicMinds, Inc", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J32967", "label": "Protechture, LLC", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J31028", "label": "GAC Solutions", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J31029", "label": "GAC Solutions", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J29286", "label": "Ram Mechanical Inc.", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J20702", "label": " EGN Consult \u0026 Recru", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J35720", "label": "Industrial Technical", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J29568", "label": "Rhino Tool House", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J15399", "label": "Professional Enginee", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J34106", "label": "Vedan Technologies", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J33708", "label": "Hire Python Develope", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J16166", "label": "Udemy", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J17102", "label": "OpenSesame", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J23925", "label": "Cephas Consultancy S", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J13500", "label": "HSI", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J10100", "label": "USM Business Systems", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J18151", "label": "SolidProfessor", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J18454", "label": "Google DeepMind", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J26422", "label": "Virtual Labs Inc.", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J20970", "label": "Lambda", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J10750", "label": "The Finders", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J34422", "label": "Cross Platform Devel", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J24818", "label": "Appzlogic ", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J13786", "label": "Datavail", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J16152", "label": "Infomatics Corp", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J16035", "label": "MongoDB", "shape": "dot", "size": 15}, {"color": "red", "font": {"color": "white"}, "id": "J9778", "label": "Pluralsight", "shape": "dot", "size": 15}]);
92
+ edges = new vis.DataSet([{"from": "C0", "title": "0.703", "to": "J9418", "value": 7.028056979179382}, {"from": "C0", "title": "0.703", "to": "J30989", "value": 7.0262110233306885}, {"from": "C0", "title": "0.703", "to": "J9417", "value": 7.02572226524353}, {"from": "C0", "title": "0.702", "to": "J30990", "value": 7.019376754760742}, {"from": "C0", "title": "0.701", "to": "J9416", "value": 7.010321617126465}, {"from": "C1", "title": "0.620", "to": "J10140", "value": 6.20457649230957}, {"from": "C1", "title": "0.620", "to": "J20529", "value": 6.201968193054199}, {"from": "C1", "title": "0.589", "to": "J30163", "value": 5.894620418548584}, {"from": "C1", "title": "0.577", "to": "J17134", "value": 5.765535235404968}, {"from": "C1", "title": "0.576", "to": "J28802", "value": 5.755815505981445}, {"from": "C2", "title": "0.619", "to": "J21756", "value": 6.18832528591156}, {"from": "C2", "title": "0.617", "to": "J9454", "value": 6.172588467597961}, {"from": "C2", "title": "0.613", "to": "J18817", "value": 6.127530932426453}, {"from": "C2", "title": "0.608", "to": "J27159", "value": 6.082639694213867}, {"from": "C2", "title": "0.600", "to": "J33214", "value": 6.003042459487915}, {"from": "C3", "title": "0.589", "to": "J26293", "value": 5.888209939002991}, {"from": "C3", "title": "0.589", "to": "J26294", "value": 5.888209939002991}, {"from": "C3", "title": "0.589", "to": "J26295", "value": 5.888209939002991}, {"from": "C3", "title": "0.589", "to": "J26296", "value": 5.888209939002991}, {"from": "C3", "title": "0.534", "to": "J27249", "value": 5.344255566596985}, {"from": "C4", "title": "0.515", "to": "J23927", "value": 5.154691934585571}, {"from": "C4", "title": "0.515", "to": "J237", "value": 5.150743722915649}, {"from": "C4", "title": "0.514", "to": "J23926", "value": 5.135759115219116}, {"from": "C4", "title": "0.506", "to": "J25745", "value": 5.0571417808532715}, {"from": "C4", "title": "0.495", "to": "J35525", "value": 4.94664192199707}, {"from": "C5", "title": "0.624", "to": "J13170", "value": 6.2363749742507935}, {"from": "C5", "title": "0.590", "to": "J27249", "value": 5.904499888420105}, {"from": "C5", "title": "0.589", "to": "J27248", "value": 5.891878008842468}, {"from": "C5", "title": "0.587", "to": "J32967", "value": 5.873211622238159}, {"from": "C5", "title": "0.567", "to": "J18817", "value": 5.669974684715271}, {"from": "C6", "title": "0.528", "to": "J23927", "value": 5.282142162322998}, {"from": "C6", "title": "0.528", "to": "J23926", "value": 5.279108881950378}, {"from": "C6", "title": "0.504", "to": "J237", "value": 5.036947131156921}, {"from": "C6", "title": "0.501", "to": "J31028", "value": 5.008084774017334}, {"from": "C6", "title": "0.501", "to": "J31029", "value": 5.008084774017334}, {"from": "C7", "title": "0.541", "to": "J29286", "value": 5.409826636314392}, {"from": "C7", "title": "0.513", "to": "J20702", "value": 5.132828950881958}, {"from": "C7", "title": "0.511", "to": "J35720", "value": 5.112812519073486}, {"from": "C7", "title": "0.511", "to": "J29568", "value": 5.1084864139556885}, {"from": "C7", "title": "0.510", "to": "J15399", "value": 5.098806619644165}, {"from": "C8", "title": "0.523", "to": "J34106", "value": 5.231214761734009}, {"from": "C8", "title": "0.521", "to": "J9454", "value": 5.210273861885071}, {"from": "C8", "title": "0.517", "to": "J20529", "value": 5.1720041036605835}, {"from": "C8", "title": "0.516", "to": "J13170", "value": 5.163518190383911}, {"from": "C8", "title": "0.514", "to": "J28802", "value": 5.135617256164551}, {"from": "C9", "title": "0.608", "to": "J33708", "value": 6.077218055725098}, {"from": "C9", "title": "0.585", "to": "J9454", "value": 5.8520495891571045}, {"from": "C9", "title": "0.570", "to": "J30990", "value": 5.695323944091797}, {"from": "C9", "title": "0.569", "to": "J30989", "value": 5.691220760345459}, {"from": "C9", "title": "0.566", "to": "J13170", "value": 5.657694339752197}, {"from": "C10", "title": "0.586", "to": "J27159", "value": 5.86123526096344}, {"from": "C10", "title": "0.586", "to": "J16166", "value": 5.860676169395447}, {"from": "C10", "title": "0.577", "to": "J26293", "value": 5.769027471542358}, {"from": "C10", "title": "0.577", "to": "J26294", "value": 5.769027471542358}, {"from": "C10", "title": "0.577", "to": "J26295", "value": 5.769027471542358}, {"from": "C11", "title": "0.593", "to": "J9454", "value": 5.932710766792297}, {"from": "C11", "title": "0.582", "to": "J17102", "value": 5.818200707435608}, {"from": "C11", "title": "0.564", "to": "J23925", "value": 5.643590092658997}, {"from": "C11", "title": "0.559", "to": "J13500", "value": 5.586053133010864}, {"from": "C11", "title": "0.553", "to": "J26293", "value": 5.532607436180115}, {"from": "C12", "title": "0.629", "to": "J20529", "value": 6.294257044792175}, {"from": "C12", "title": "0.623", "to": "J30163", "value": 6.232224702835083}, {"from": "C12", "title": "0.623", "to": "J10140", "value": 6.227796673774719}, {"from": "C12", "title": "0.592", "to": "J28802", "value": 5.915536284446716}, {"from": "C12", "title": "0.587", "to": "J10100", "value": 5.873672366142273}, {"from": "C13", "title": "0.511", "to": "J18151", "value": 5.108709931373596}, {"from": "C13", "title": "0.509", "to": "J13170", "value": 5.0925469398498535}, {"from": "C13", "title": "0.507", "to": "J18454", "value": 5.072507858276367}, {"from": "C13", "title": "0.491", "to": "J26422", "value": 4.905799925327301}, {"from": "C13", "title": "0.489", "to": "J20970", "value": 4.894821345806122}, {"from": "C14", "title": "0.545", "to": "J10750", "value": 5.44858992099762}, {"from": "C14", "title": "0.530", "to": "J30989", "value": 5.3042155504226685}, {"from": "C14", "title": "0.529", "to": "J30990", "value": 5.2928584814071655}, {"from": "C14", "title": "0.526", "to": "J34422", "value": 5.2603888511657715}, {"from": "C14", "title": "0.508", "to": "J24818", "value": 5.0799620151519775}, {"from": "C15", "title": "0.595", "to": "J13786", "value": 5.954039692878723}, {"from": "C15", "title": "0.566", "to": "J16152", "value": 5.656808614730835}, {"from": "C15", "title": "0.565", "to": "J30989", "value": 5.64922571182251}, {"from": "C15", "title": "0.564", "to": "J30990", "value": 5.64068078994751}, {"from": "C15", "title": "0.561", "to": "J16035", "value": 5.613973140716553}, {"from": "C16", "title": "0.654", "to": "J9454", "value": 6.5383148193359375}, {"from": "C16", "title": "0.629", "to": "J30990", "value": 6.292245984077454}, {"from": "C16", "title": "0.628", "to": "J26293", "value": 6.2770432233810425}, {"from": "C16", "title": "0.628", "to": "J26294", "value": 6.2770432233810425}, {"from": "C16", "title": "0.628", "to": "J26295", "value": 6.2770432233810425}, {"from": "C17", "title": "0.594", "to": "J21756", "value": 5.936995148658752}, {"from": "C17", "title": "0.573", "to": "J20529", "value": 5.727492570877075}, {"from": "C17", "title": "0.569", "to": "J13170", "value": 5.693559050559998}, {"from": "C17", "title": "0.569", "to": "J33214", "value": 5.69225549697876}, {"from": "C17", "title": "0.567", "to": "J18817", "value": 5.669708847999573}, {"from": "C18", "title": "0.587", "to": "J10750", "value": 5.866515636444092}, {"from": "C18", "title": "0.578", "to": "J30989", "value": 5.7807475328445435}, {"from": "C18", "title": "0.577", "to": "J30990", "value": 5.771228671073914}, {"from": "C18", "title": "0.562", "to": "J34422", "value": 5.615531802177429}, {"from": "C18", "title": "0.549", "to": "J9454", "value": 5.493091940879822}, {"from": "C19", "title": "0.626", "to": "J9454", "value": 6.2596118450164795}, {"from": "C19", "title": "0.596", "to": "J18817", "value": 5.959857702255249}, {"from": "C19", "title": "0.578", "to": "J34106", "value": 5.777912735939026}, {"from": "C19", "title": "0.574", "to": "J13170", "value": 5.7445597648620605}, {"from": "C19", "title": "0.572", "to": "J9778", "value": 5.723878741264343}]);
93
+
94
+ nodeColors = {};
95
+ allNodes = nodes.get({ returnType: "Object" });
96
+ for (nodeId in allNodes) {
97
+ nodeColors[nodeId] = allNodes[nodeId].color;
98
+ }
99
+ allEdges = edges.get({ returnType: "Object" });
100
+ // adding nodes and edges to the graph
101
+ data = {nodes: nodes, edges: edges};
102
+
103
+ var options = {"physics": {"enabled": true, "solver": "forceAtlas2Based"}};
104
+
105
+
106
+
107
+
108
+
109
+
110
+ network = new vis.Network(container, data, options);
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ return network;
122
+
123
+ }
124
+ drawGraph();
125
+ </script>
126
+ </body>
127
+ </html>