【问题标题】:Document Sentiment Magnitude != sum(Sentence Magnitude)文档情感量 != sum(Sentence Magnitude)
【发布时间】:2019-07-09 03:40:21
【问题描述】:

我目前正在使用 google cloud NL api 进行一些分析新闻文章的测试。最初我很好奇文档大小是如何计算的,在这里搜索得到了

Google Cloud Natural Language API - How is document magnitude calculated?

其中提到它是构成句子量级的总和。

在我自己的测试中,我发现情况并非如此。有什么我可能做错了吗?


为了清楚起见,我在 conda 环境中使用正在运行的 Python 3.7.3,并使用从 conda-forge 获得的 google-cloud-language。

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)

【问题讨论】:

  • 你能举个例子吗?

标签: google-cloud-nl magnitude


【解决方案1】:

从另一个线程有时可能只是绝对总和,但并非总是如此。

Google Natural Language Sentiment Analysis Aggregate Scores

“聚合的工作方式是将输入文本分解成更小的组件,通常是 ngram,这可能是文档讨论聚合的原因,但是,聚合不是简单的加法,不能总结个人情绪每个实体的值得到总分。”

我认为这是分数和量级计算的情况。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-09
  • 1970-01-01
  • 2020-01-30
  • 1970-01-01
  • 2015-04-11
  • 2014-07-16
  • 2020-08-20
相关资源
最近更新 更多