Could anyone derive a formula for this?

148 Views Asked by At

Edited:

I want to get a sentiment score of various sentences and I've tried coming up with an equation that could satisfy the conditions that are inherent to each sentence (It's estimated mood as well as a probability of each mood) that are determined by a 3rd part service. The value I want to get - the score - gets its value from these 2 conditions or variables - the mood with 3 states (either positive, neutral, negative) and a probability for each (0.0 - 1.0), which gives the score a possible range from 0 - 100. I added the score values in myself, so they aren't an exact science, but the ranges worked out to be 0-39 for negative moods, 40-60 for neutral moods, and up to 100 for positive moods, as a continuum. I'm hoping to get something like the following that will make the scores roughly similar to those set out below:

score = mood * probability * (some kind of weighting)

Rough score values:

if mood == positive && probability > 0.94
   score = 100
elsif
   mood == positive && probability > 0.89
   score = 96
elsif
   mood == positive && probability > 0.84
   score = 92
elsif
   mood == positive && probability > 0.79
   score = 88
elsif
   mood == positive && probability > 0.74
   score = 86
elsif
   mood == positive && probability > 0.69
   score = 84
elsif
   mood == positive && probability > 0.64
   score = 82
elsif
   mood == positive && probability > 0.59
   score = 80
elsif
   mood == positive && probability > 0.54
   score = 78
elsif
   mood == positive && probability > 0.49
   score = 76
elsif
   mood == positive && probability > 0.44
   score = 74
elsif
   mood == positive && probability > 0.39
   score = 72
elsif
   mood == positive && probability > 0.34
   score = 70
elsif
   mood == positive && probability > 0.29
   score = 68
elsif
   mood == positive && probability > 0.24
   score = 66
elsif
   mood == positive && probability > 0.19
   score = 64
elsif
   mood == positive && probability > 0.14
   score = 62
elsif
   mood == positive && probability > 0
   score = 60
elsif
   mood == neutral && probability > 0.94
   score = 59
elsif
  mood == neutral && probability > 0.89
  score = 58
elsif
  mood == neutral && probability > 0.84
  score = 57
elsif
  mood == neutral && probability > 0.79
  score = 56
elsif
  mood == neutral && probability > 0.74
  score = 55
elsif
  mood == neutral && probability > 0.69
  score = 53
elsif
  mood == neutral && probability > 0.64
  score = 52
elsif
  mood == neutral && probability > 0.59
  score = 51
elsif
  mood == neutral && probability > 0.54
  score = 50
elsif
  mood == neutral && probability > 0.49
  score = 49
elsif
  mood == neutral && probability > 0.44
  score = 48
elsif
  mood == neutral && probability > 0.39
  score = 47
elsif
  mood == neutral && probability > 0.34
  score = 46
elsif
  mood == neutral && probability > 0.29
  score = 45
elsif
  mood == neutral && probability > 0.24
  score = 43
elsif
  mood == neutral && probability > 0.19
  score = 42
elsif
  mood == neutral && probability > 0.14
  score = 41
elsif
  mood == neutral && probability > 0
  score = 40
elsif
  mood == negative && probability > 0.94
  score = 39
elsif
  mood == negative && probability > 0.89
  score = 38
elsif
  mood == negative && probability > 0.84
  score = 36
elsif
  mood == negative && probability > 0.79
  score = 34
elsif
  mood == negative && probability > 0.74
  score = 32
elsif
  mood == negative && probability > 0.69
  score = 30
elsif
  mood == negative && probability > 0.64
  score = 28
elsif
  mood == negative && probability > 0.59
  score = 26
elsif
  mood == negative && probability > 0.54
  score = 24
elsif
  mood == negative && probability > 0.49
  score = 22
elsif
  mood == negative && probability > 0.44
  score = 20
elsif
  mood == negative && probability > 0.39
  score = 18
elsif
  mood == negative && probability > 0.34
  score = 16
elsif
  mood == negative && probability > 0.29
  score = 14
elsif
  mood == negative && probability > 0.24
  score = 12
elsif
  mood == negative && probability > 0.19
  score = 10
elsif
  mood == negative && probability > 0.14
  score = 8
else
  mood == negative && probability > 0
  score = 3
end