update
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,8 +2,6 @@
|
||||
*/node_modules
|
||||
.DS_Store
|
||||
|
||||
*~/backend/index.js
|
||||
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ const pool = mysql.createPool({
|
||||
host: "localhost",
|
||||
user: "root",
|
||||
database: "marketplace",
|
||||
password: "12345678",
|
||||
});
|
||||
|
||||
//Export a promise for promise-based query
|
||||
|
||||
@@ -70,7 +70,7 @@ function App() {
|
||||
email: userData.email,
|
||||
// Add any other required fields
|
||||
}),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -119,7 +119,7 @@ function App() {
|
||||
email: tempUserData.email,
|
||||
code: code,
|
||||
}),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -163,7 +163,7 @@ function App() {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(userData),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -222,11 +222,12 @@ function App() {
|
||||
setError("Email and password are required");
|
||||
setIsLoading(false);
|
||||
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 {
|
||||
if (isSignUp) {
|
||||
// Handle Sign Up with verification
|
||||
@@ -265,7 +266,7 @@ function App() {
|
||||
email: formValues.email,
|
||||
password: formValues.password,
|
||||
}),
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -509,8 +510,8 @@ function App() {
|
||||
{isLoading
|
||||
? "Please wait..."
|
||||
: isSignUp
|
||||
? "Create Account"
|
||||
: "Sign In"}
|
||||
? "Create Account"
|
||||
: "Sign In"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user