Skip to content

Commit 3f232a1

Browse files
committed
listerv check and reccomendation
1 parent e39f49a commit 3f232a1

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

convex/listserv.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from "react";
2+
3+
export default function App() {
4+
//Example emails
5+
const emails = [
6+
"acsu-l@list.cornell.edu",
7+
"cs-l@cornell.edu",
8+
"startupclub@cornell.edu",
9+
"friend@gmail.com"
10+
];
11+
//Will need to be modified depending on our database schema
12+
function detectListserv(emails) {
13+
const results = [];
14+
15+
for (const email of emails) {
16+
const username = email.split("@")[0];
17+
18+
if (username.includes("-l")) {
19+
results.push("LISTSERV");
20+
} else {
21+
results.push("NOT LISTSERV");
22+
}
23+
}
24+
25+
return results;
26+
}
27+
28+
const results = detectListserv(emails);
29+
30+
return (
31+
<div>
32+
<h2>Email Classification</h2>
33+
{emails.map((email, index) => (
34+
<p key={index}>
35+
{email} {results[index]}
36+
</p>
37+
))}
38+
</div>
39+
);
40+
}

convex/reccomendation.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React from "react";
2+
3+
export default function App() {
4+
//Example profile
5+
const userProfile = {
6+
major: "CS",
7+
interests: ["AI", "Startups", "Robotics"],
8+
tags: ["machine learning", "entrepreneurship"]
9+
};
10+
//Example events for different listservs.
11+
const events = [
12+
{
13+
id: 1,
14+
title: "Intro to AI Workshop",
15+
majorTags: ["CS"],
16+
interestTags: ["AI"],
17+
descriptionTags: ["machine learning"]
18+
},
19+
{
20+
id: 2,
21+
title: "Finance Networking Night",
22+
majorTags: ["Econ"],
23+
interestTags: ["Finance"],
24+
descriptionTags: ["investment banking"]
25+
},
26+
{
27+
id: 3,
28+
title: "Startup Hackathon",
29+
majorTags: ["CS", "Business"],
30+
interestTags: ["Startups"],
31+
descriptionTags: ["entrepreneurship"]
32+
}
33+
];
34+
35+
//Reccomendation algorithm will me fine tuned to match database schema decisions.
36+
function recommendEvents(user, events) {
37+
return events
38+
.map(event => {
39+
let score = 0;
40+
41+
if (event.majorTags.includes(user.major)) score += 3;
42+
43+
const interestMatches = event.interestTags.filter(tag =>
44+
user.interests.includes(tag)
45+
).length;
46+
47+
const tagMatches = event.descriptionTags.filter(tag =>
48+
user.tags.includes(tag)
49+
).length;
50+
51+
score += interestMatches * 2;
52+
score += tagMatches * 2;
53+
54+
return { ...event, score };
55+
})
56+
.filter(event => event.score > 0)
57+
.sort((a, b) => b.score - a.score);
58+
}
59+
60+
const recommended = recommendEvents(userProfile, events);
61+
62+
return (
63+
<div style={{ padding: "20px" }}>
64+
<h2>Recommended Events</h2>
65+
66+
{recommended.map(event => (
67+
<div key={event.id} style={{ marginBottom: "10px" }}>
68+
<strong>{event.title}</strong>
69+
<p>Score: {event.score}</p>
70+
</div>
71+
))}
72+
</div>
73+
);
74+
}

0 commit comments

Comments
 (0)