update
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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
|
||||||
|
|||||||
@@ -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",
|
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
|
||||||
|
|||||||
@@ -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) {
|
||||||
@@ -509,8 +510,8 @@ function App() {
|
|||||||
{isLoading
|
{isLoading
|
||||||
? "Please wait..."
|
? "Please wait..."
|
||||||
: isSignUp
|
: isSignUp
|
||||||
? "Create Account"
|
? "Create Account"
|
||||||
: "Sign In"}
|
: "Sign In"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user