| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- const cosineSimilarity = require('compute-cosine-similarity')
-
- const config = require('./config')
-
- const preComputedScores = {
- 100: {
- 100: 0,
- 140: 0,
- 180: 0,
- 220: 0,
- 260: 0,
- 400: 0,
- },
- 140: {
- 100: 0,
- 140: 0,
- 180: 0,
- 220: 0,
- 260: 0,
- 400: 0,
- },
- 180: {
- 100: 0,
- 140: 0,
- 180: 0,
- 220: 0,
- 260: 0,
- 400: 0,
- },
- 220: {
- 100: 0,
- 140: 0,
- 180: 0,
- 220: 0,
- 260: 0,
- 400: 0,
- },
- 260: {
- 100: 0,
- 140: 0,
- 180: 0,
- 220: 0,
- 260: 0,
- 400: 0,
- },
- 400: {
- 100: 0,
- 140: 0,
- 180: 0,
- 220: 0,
- 260: 0,
- 400: 0,
- },
- }
- 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,
- )
- }
- config.scoreVals.forEach(val => {
- config.scoreVals.forEach(v => {
- preComputedScores[val][v] = score2d(val, v)
- })
- })
-
- module.exports = {
- precomputed: preComputedScores,
- }
|