saherPervaiz commited on
Commit
8b29264
·
verified ·
1 Parent(s): d6f26da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -16,7 +16,7 @@ def get_scholarships(country, interests):
16
 
17
  if response.status_code == 200:
18
  posts = response.json()[:5] # Take only the first 5 posts as mock scholarships
19
- return [{"title": f"Scholarship {i+1}", "description": post['body'], "eligibility": "Any student from any background."} for i, post in enumerate(posts)]
20
  else:
21
  return []
22
 
@@ -34,7 +34,7 @@ def get_internships(country):
34
  # Function to recommend opportunities based on user input
35
  def recommend_opportunities(user_interests, user_skills, opportunities):
36
  user_profile = [f"{user_interests} {user_skills}"]
37
- opportunities_text = [f"{opportunity['description']} {opportunity['eligibility']}" for opportunity in opportunities]
38
 
39
  # Vectorize the text using TF-IDF
40
  vectorizer = TfidfVectorizer(stop_words='english')
@@ -68,8 +68,8 @@ if submit_button:
68
  st.write("Scholarships found:")
69
  for scholarship in scholarships:
70
  st.write(f"Title: {scholarship['title']}")
71
- st.write(f"Description: {scholarship['description']}")
72
- st.write(f"Eligibility: {scholarship['eligibility']}")
73
  st.write("---")
74
  else:
75
  st.write("No scholarships found for the selected country.")
@@ -93,6 +93,6 @@ if submit_button:
93
  st.write("AI-based Recommended Opportunities based on your profile:")
94
  for opportunity in recommended_opportunities:
95
  st.write(f"Title: {opportunity['title']}")
96
- st.write(f"Description: {opportunity['description']}")
97
  st.write(f"Eligibility: {opportunity.get('eligibility', 'Not available')}")
98
  st.write("---")
 
16
 
17
  if response.status_code == 200:
18
  posts = response.json()[:5] # Take only the first 5 posts as mock scholarships
19
+ return [{"title": f"Scholarship {i+1}", "description": post.get('body', 'No description available'), "eligibility": "Any student from any background."} for i, post in enumerate(posts)]
20
  else:
21
  return []
22
 
 
34
  # Function to recommend opportunities based on user input
35
  def recommend_opportunities(user_interests, user_skills, opportunities):
36
  user_profile = [f"{user_interests} {user_skills}"]
37
+ opportunities_text = [f"{opportunity.get('description', 'No description available')} {opportunity.get('eligibility', 'No eligibility available')}" for opportunity in opportunities]
38
 
39
  # Vectorize the text using TF-IDF
40
  vectorizer = TfidfVectorizer(stop_words='english')
 
68
  st.write("Scholarships found:")
69
  for scholarship in scholarships:
70
  st.write(f"Title: {scholarship['title']}")
71
+ st.write(f"Description: {scholarship.get('description', 'No description available')}")
72
+ st.write(f"Eligibility: {scholarship.get('eligibility', 'No eligibility available')}")
73
  st.write("---")
74
  else:
75
  st.write("No scholarships found for the selected country.")
 
93
  st.write("AI-based Recommended Opportunities based on your profile:")
94
  for opportunity in recommended_opportunities:
95
  st.write(f"Title: {opportunity['title']}")
96
+ st.write(f"Description: {opportunity.get('description', 'No description available')}")
97
  st.write(f"Eligibility: {opportunity.get('eligibility', 'Not available')}")
98
  st.write("---")