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 < / h 2 >
65+
66+ { recommended . map ( event => (
67+ < div key = { event . id } style = { { marginBottom : "10px" } } >
68+ < strong > { event . title} < / s t r o n g >
69+ < p > Score : { event . score } < / p >
70+ < / div >
71+ ) ) }
72+ < / div >
73+ ) ;
74+ }
0 commit comments