This commit is contained in:
Mann Patel
2025-03-23 20:16:19 -06:00
parent ee6df0f674
commit 148fe95a11
6 changed files with 11 additions and 56 deletions

2
.gitignore vendored
View File

@@ -2,8 +2,6 @@
*/node_modules */node_modules
.DS_Store .DS_Store
*~/backend/index.js
.vscode/* .vscode/*
!.vscode/extensions.json !.vscode/extensions.json
.idea .idea

View File

@@ -1,43 +0,0 @@
package main
import (
"fmt"
"math"
)
func cosine(x, y []int) float64 {
var dotProduct, normX, normY float64
for i := 1; i < len(x); i++ {
dotProduct += float64(x[i] * y[i])
normX += float64(x[i] * x[i])
normY += float64(y[i] * y[i])
}
return dotProduct / (math.Sqrt(normX) * math.Sqrt(normY))
}
func main() {
history := [][]int{
{1, 0, 1, 0},
{0, 1, 0, 1},
{1, 0, 1, 1},
}
productCategory := [][]int{
{1, 1, 0, 0},
{0, 0, 0, 1},
{0, 0, 1, 0},
{0, 0, 1, 1},
{0, 1, 0, 0},
{0, 1, 1, 1},
{1, 1, 1, 0},
{0, 0, 0, 1},
{1, 1, 1, 1},
}
// Calculate similarity between first search and each product
for i, product := range productCategory {
sim := cosine(history[0], product)
fmt.Printf("Similarity with product %d: %f\n", i, sim)
}
}

View File

@@ -5,7 +5,6 @@ const pool = mysql.createPool({
host: "localhost", host: "localhost",
user: "root", user: "root",
database: "marketplace", database: "marketplace",
password: "12345678",
}); });
//Export a promise for promise-based query //Export a promise for promise-based query

View File

@@ -70,7 +70,7 @@ function App() {
email: userData.email, email: userData.email,
// Add any other required fields // Add any other required fields
}), }),
} },
); );
if (!response.ok) { if (!response.ok) {
@@ -119,7 +119,7 @@ function App() {
email: tempUserData.email, email: tempUserData.email,
code: code, code: code,
}), }),
} },
); );
if (!response.ok) { if (!response.ok) {
@@ -163,7 +163,7 @@ function App() {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify(userData), body: JSON.stringify(userData),
} },
); );
if (!response.ok) { if (!response.ok) {
@@ -222,11 +222,12 @@ function App() {
setError("Email and password are required"); setError("Email and password are required");
setIsLoading(false); setIsLoading(false);
return; return;
} else if (!formValues.email.endsWith("@ucalgary.ca")) {
setError("Please use your UCalgary email address (@ucalgary.ca)");
setIsLoading(false);
return;
} }
// else if (!formValues.email.endsWith("@ucalgary.ca")) {
// setError("Please use your UCalgary email address (@ucalgary.ca)");
// setIsLoading(false);
// return;
// }
try { try {
if (isSignUp) { if (isSignUp) {
// Handle Sign Up with verification // Handle Sign Up with verification
@@ -265,7 +266,7 @@ function App() {
email: formValues.email, email: formValues.email,
password: formValues.password, password: formValues.password,
}), }),
} },
); );
if (!response.ok) { if (!response.ok) {