-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenhance_data.py
More file actions
202 lines (164 loc) · 6.85 KB
/
enhance_data.py
File metadata and controls
202 lines (164 loc) · 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env python3
"""
Quick script to enhance the existing repository data with sample AI tags and featured assessments
for demonstration purposes.
"""
import json
import random
from datetime import datetime, timedelta
def generate_sample_tags(repo_name, description, language):
"""Generate sample AI tags based on repository characteristics."""
tags = []
# Healthcare keywords
healthcare_terms = ['clinical', 'patient', 'medical', 'healthcare', 'hospital', 'emergency', 'pharmacy', 'dental']
technical_terms = ['api', 'integration', 'data', 'analytics', 'automation', 'dashboard', 'monitoring']
department_terms = ['emergency department', 'radiology', 'pathology', 'dental services', 'referrals']
name_lower = repo_name.lower()
desc_lower = (description or '').lower()
# Add healthcare tags
for term in healthcare_terms:
if term in name_lower or term in desc_lower:
tags.append(term.title())
# Add technical tags
for term in technical_terms:
if term in name_lower or term in desc_lower:
tags.append(term.title())
# Add department tags
for term in department_terms:
if any(word in name_lower or word in desc_lower for word in term.split()):
tags.append(term.title())
# Add language-based tags
if language:
tags.append(f"{language} Development")
# Remove duplicates and limit to 5 tags
tags = list(set(tags))[:5]
# If no tags generated, add some generic ones
if not tags:
if 'integration' in name_lower or 'hub' in name_lower:
tags = ['Integration', 'Healthcare Systems']
elif 'ui' in name_lower or 'mock' in name_lower:
tags = ['User Interface', 'Testing']
elif language:
tags = [f"{language} Application"]
else:
tags = ['Healthcare Solution']
return tags
def assess_quality(repo):
"""Assess repository quality for featured eligibility."""
score = 0
criteria_met = []
missing_criteria = []
# Required fields (20 points each)
if repo.get('name'):
score += 20
criteria_met.append('name')
else:
missing_criteria.append('name')
if repo.get('owner', {}).get('login'):
score += 20
criteria_met.append('owner')
else:
missing_criteria.append('owner')
if repo.get('language'):
score += 20
criteria_met.append('language')
else:
missing_criteria.append('language')
# Description (15 points)
if repo.get('description') and len(repo['description'].strip()) > 10:
score += 15
criteria_met.append('description')
else:
missing_criteria.append('description')
# Tags (15 points)
total_tags = len(repo.get('topics', [])) + len(repo.get('generated_tags', []))
if total_tags >= 2:
score += 15
criteria_met.append('tags')
else:
missing_criteria.append('tags')
# Recent activity (15 points)
if repo.get('updated_at'):
try:
updated_date = datetime.fromisoformat(repo['updated_at'].replace('Z', '+00:00'))
six_months_ago = datetime.now().replace(tzinfo=updated_date.tzinfo) - timedelta(days=180)
if updated_date > six_months_ago:
score += 15
criteria_met.append('recent_activity')
else:
missing_criteria.append('recent_activity')
except:
missing_criteria.append('recent_activity')
else:
missing_criteria.append('recent_activity')
# License (5 points bonus)
if repo.get('license'):
score += 5
criteria_met.append('license')
# Determine eligibility
required_criteria = ['name', 'owner', 'language']
has_required = all(criterion in criteria_met for criterion in required_criteria)
eligible = score >= 80 and has_required
return {
'eligible': eligible,
'score': score,
'criteria_met': criteria_met,
'missing_criteria': missing_criteria
}
def enhance_repositories():
"""Enhance the existing repository data."""
print("🤖 Enhancing repository data with AI tags and quality assessments...")
# Load existing data
with open('/workspaces/Solutions-Exchange/data/repositories.json', 'r') as f:
repositories = json.load(f)
print(f"📊 Processing {len(repositories)} repositories...")
enhanced_count = 0
featured_eligible = 0
for repo in repositories:
# Generate AI tags if none exist
if not repo.get('generated_tags'):
generated_tags = generate_sample_tags(
repo['name'],
repo.get('description'),
repo.get('language')
)
repo['generated_tags'] = generated_tags
# Update all_tags
all_tags = list(set(repo.get('topics', []) + generated_tags))
repo['all_tags'] = all_tags
enhanced_count += 1
# Assess quality for featuring
if not repo.get('featured'):
assessment = assess_quality(repo)
repo['featured'] = assessment
if assessment['eligible']:
featured_eligible += 1
# Save enhanced data
with open('/workspaces/Solutions-Exchange/data/repositories.json', 'w') as f:
json.dump(repositories, f, indent=2, ensure_ascii=False)
print(f"✅ Enhanced {enhanced_count} repositories with AI tags")
print(f"⭐ {featured_eligible} repositories qualify for featuring")
print(f"📈 Quality assessment completed for all {len(repositories)} repositories")
# Show some stats
languages = {}
organizations = {}
for repo in repositories:
# Count languages
lang = repo.get('language') or 'Unknown'
languages[lang] = languages.get(lang, 0) + 1
# Count organizations
org = repo.get('owner', {}).get('login', 'Unknown')
organizations[org] = organizations.get(org, 0) + 1
print(f"\n📊 Repository Statistics:")
print(f" • Languages: {len(languages)} different languages")
print(f" • Organizations: {len(organizations)} organizations")
print(f" • Featured eligible: {featured_eligible}/{len(repositories)} ({(featured_eligible/len(repositories)*100):.1f}%)")
# Show top featured candidates
featured_repos = [r for r in repositories if r.get('featured', {}).get('eligible')]
if featured_repos:
top_featured = sorted(featured_repos, key=lambda x: x['featured']['score'], reverse=True)[:5]
print(f"\n⭐ Top Featured Candidates:")
for repo in top_featured:
print(f" • {repo['name']} ({repo['featured']['score']}/100) - {repo['owner']['login']}")
if __name__ == "__main__":
enhance_repositories()