| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- const cosineSimilarity = require('compute-cosine-similarity')
-
- const config = require('./config')
-
- const preComputedScores = {
- 100: {
- 100: 1000,
- 140: 872,
- 180: 675,
- 220: 518,
- 260: 406,
- 400: 215,
- },
- 140: {
- 100: 872,
- 140: 1000,
- 180: 938,
- 220: 828,
- 260: 723,
- 400: 486,
- },
- 180: {
- 100: 675,
- 140: 938,
- 180: 1000,
- 220: 968,
- 260: 906,
- 400: 706,
- },
- 220: {
- 100: 518,
- 140: 828,
- 180: 968,
- 220: 1000,
- 260: 982,
- 400: 847,
- },
- 260: {
- 100: 406,
- 140: 723,
- 180: 906,
- 220: 982,
- 260: 1000,
- 400: 928,
- },
- 400: {
- 100: 215,
- 140: 486,
- 180: 706,
- 220: 847,
- 260: 928,
- 400: 1000,
- },
- }
- const score2d = (a, b) => {
- const aScorePlusBase = [100]
- const bScorePlusBase = [100]
- aScorePlusBase.push(a)
- bScorePlusBase.push(b)
- return Math.round(
- Math.pow(cosineSimilarity(aScorePlusBase, bScorePlusBase), 10) *
- config.magic,
- )
- }
-
- // Uncomment to rerun precompute
- // config.scoreVals.forEach(val => {
- // config.scoreVals.forEach(v => {
- // preComputedScores[val][v] = score2d(val, v)
- // })
- // })
-
- module.exports = {
- precomputed: preComputedScores,
- }
|