I am currently utilizing the google cloud NL api for some tests where I analyze news articles. I was initially curious about how document magnitude was calculated, and searches here yielded
Google Cloud Natural Language API - How is document magnitude calculated?
where it was mentioned to be the sum of constituent sentence magnitudes.
In my own tests, I have found that this was not the case. Is there any thing I might be doing wrong?
For clarity, I am using the running Python 3.7.3 in a conda environment with google-cloud-language obtained from conda-forge.
document =types.Document(content = str, type = enums.Document.Type.PLAIN_TEXT)
sentiment = client.analyze_sentiment(document=document)
sentence_sents = sentiment.sentences
test_mag = 0
for sent_obj in sentence_sents:
test_mag += sent_obj.sentiment.magnitude
print(sentiment.document_sentiment.magnitude)
print(test_mag)