'How to get generate compound sentiment score using flair python

I have recently been learning how to use flair for sentiment analysis in python. I have previously been using vaderSentiment. I have been saving the sentiment scores as a compound score (ranging between -1 and 1, with -1 being most negative, 0 being neutral and 1 being most positive)

Is there a way to get this same number from flair?

I have tried

from flair.models import TextClassifier
from flair.data import Sentence

classifier = TextClassifier.load('en-sentiment')
sentence = Sentence('The food was great!')
classifier.predict(sentence)

Which only returns a value for one of the categories, In this instance it returns

Sentence: "The food was great !"   [− Tokens: 5  − Sentence-Labels: {'label': [POSITIVE (0.9961)]}]

What is the easiest way of combining these to a compound score?

Many thanks for your time



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source