I am trying to transform some data. Currently i am using the google natural language api to return scores of between -1 and 1 based on sentiment of some text.
I need to change the output so that -1 (min) is represented by 1 and 1 (max) is represented by 10. This would mean that a score of 0 (mid) returns 5.5.
I dropped maths at school...
Could anyone help? I feel like this is beyond me.
var newScore = oldScore * 9 / 2 + 5.5;
The old score has a range of 2 and the new score has a range of 9, so multiply the score by 9 and divide by 2. The resulting range will be from -4.5 to 4.5, so add 5.5 to get it to be from 1 to 10.