random bugfixes

This commit is contained in:
Robert Bendun 2021-03-29 03:51:23 +02:00
parent eeb5ef4948
commit 1855013f8b
2 changed files with 3 additions and 3 deletions

View File

@ -101,7 +101,7 @@ class Knowledge {
static arrangement
constructor(definition) {
Knowledge.fullSemanticNetwork = new SemanticNetwork(definition)
Knowledge.semanticNetwork = new SemanticNetwork(definition)
Knowledge.agentSemanticNetwork = new AgentSemanticNetwork(definition)
Knowledge.arrangement = new Arrangement()
}

View File

@ -1,5 +1,5 @@
class Shop {
productsSimilarityScore(name1, name2) {
static productsSimilarityScore(name1, name2) {
const [ o1, o2 ] = [name1, name2].map(name => Knowledge.semanticNetwork.findByName(name))
if (!o1 || !o2)
throw new Error("names should be in semantic network!")
@ -10,7 +10,7 @@ class Shop {
const set = new Set([...o1[p], ...o2[p]])
const matching = o1[p].reduce((s, v) => s + (o2[p].indexOf(v) >= 0 ? 1 : 0), 0)
return matching / [...set].lengthsss
return matching / [...set].length
}
const [ l, c ] = [calcScore('locations'), calcScore('categories')]