-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground.js
32 lines (28 loc) · 1.09 KB
/
playground.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {generateEmbedding, cosineSimilarity, semanticSearch} = require('./routes/SemanticSearch')
// const text1 = "It's raining outside.";
// const text2 = "The weather is rainy.";
// const text3 = "I gonna go shopping.";
// generateEmbedding(text2)
// .then(embedding1 => {
// generateEmbedding(text3)
// .then(embedding2 => {
// similarity = cosineSimilarity(embedding1, embedding2);
// console.log(similarity);
// })
// });
let targetList = [
"It's raining cats and dogs outside",
"It's pouring rain outside",
"The weather outside is awful, it's a complete downpour",
"The rain is coming down heavily outside",
"Outside, it's a torrential downpour",
"I need to pick up some groceries",
"I need to do some grocery shopping",
"I have to buy some groceries",
"I need to go shopping for food",
"I need to get some food from the supermarket"
];
let serachTerm = "It's raining outside.";
semanticSearch(serachTerm, targetList, 8)
.then(res => console.log(res))
.catch(err => console.log(err));