Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

match-maker.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const similarity = require('compute-cosine-similarity')
  2. const magic = 1000
  3. const ScoreKeeper = {
  4. score: (seeker, potentialMatch) => {
  5. const seekerResponseValues = seeker.profileResponses.map(res =>
  6. parseInt(Object.values(res)),
  7. )
  8. const potentialMatchResponseValues =
  9. potentialMatch.profileResponses.map(res =>
  10. parseInt(Object.values(res)),
  11. )
  12. return Math.floor(
  13. similarity(seekerResponseValues, potentialMatchResponseValues) *
  14. magic,
  15. )
  16. },
  17. }
  18. module.exports = class MatchMaker {
  19. constructor(settings) {
  20. this.proposer = settings.proposer
  21. // Score main profile
  22. this.keeper = ScoreKeeper
  23. }
  24. runPrematch(settings) {
  25. // grab all profiles form the db
  26. // grab all responses
  27. // grab all response keys
  28. // create a full response object
  29. // create a full profile of responses
  30. const unscreenedProfiles = []
  31. const screenedProfiles = []
  32. for (const profile in unscreenedProfiles) {
  33. // Do something here
  34. if (!settings) {
  35. return
  36. }
  37. screenedProfiles.push(profile)
  38. }
  39. return screenedProfiles
  40. }
  41. matchFor(proposer, profiles, settings) {
  42. // Do something here
  43. return this.runPrematch(profiles, settings)
  44. }
  45. scoreProfiles(profiles) {
  46. const matchScores = []
  47. for (const profile in this.profiles) {
  48. const scored = this.keeper.score(profile)
  49. matchScores.push(scored)
  50. }
  51. return matchScores
  52. }
  53. }