附代码 基于NLP的COVID-19虚假新闻检测( 三 )

polarity_source.py

附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
图十
这意味着《纽约时报》的新闻和数据中的自然新闻听起来不那么具有情绪 。
可以用以下小提琴图(violin plot)来证实:
1. fig = go.Figure()2.3. sources = ['https://www.health.harvard.edu/', 'https://www.nytimes.com/', 'Facebook', 'https://www.naturalnews.com/']4.5. for source in sources:6.fig.add_trace(go.Violin(x=df['source'][df['source'] == source],7.y=df['polarity'][df['source'] == source],8.name=source,9.box_visible=True,10.meanline_visible=True))11. fig.update_layout(title_text='Polarity of four sources', template='plotly_white')12. fig.show()source_violin.py
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
图十一
  • 情绪vs文章长度vs真实性
我注意到我收集的新闻和帖子既不是非常积极 , 也不是非常消极 。它们大多数处于适度的正数范围内 , 并且大多数长度少于1000个字 。
1. fig = px.density_contour(df, x='polarity', y='text_len', marginal_x='histogram', marginal_y='histogram', template='plotly_white')2. fig.update_layout(title_text='Sentiment vs. Article length')3. fig.show()len_polarity.py
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
图十二
情感与文章的长度之间没有明显的关系 。通常 , 文章的情感或篇幅不能反映其真实性 。虚假新闻与真实新闻之间的区别可能是相当随意的 。
1. fig = px.scatter(df, x='polarity', y='text_len', color='label', template="plotly_white")2. fig.update_layout(title_text='Sentiment polarity')3. fig.show()polarity_scatter.py
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
图十三
df.groupby(['source']).mean().sort_values('polarity', ascending=False)
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
图十四
我注意到鲁迪·朱利安妮(Rudy Giuliani)的帖子是情感评分最高的帖子之一 , 所以我很好奇想知道这篇帖子是关于什么的:
df.loc[df['source'] == 'RudyGiuliani']['text'][880]
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
当然是关于羟氯喹(Hydroxychloroquine)的啦~ 。
真实与虚假新闻的内容
现在 , 我们将了解数据集中包含哪些主题:
1. common_bigram_true = get_top_n_bigram(df.loc[df['label'] == 'TRUE']['text'], 20)2. for word, freq in common_bigram_true:3.print(word, freq)true_bigram.py
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
1. common_bigram_fake = get_top_n_bigram(df.loc[df['label'] == 'FAKE']['text'], 20)2. for word, freq in common_bigram_fake:3.print(word, freq)fake_bigram.py
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
  • 促进治愈:这包括使用大剂量静脉注射维生素C 。
  • 关于起源的推测:这个主题包括声称冠状病毒是在用于生物武器的实验室中制造的 , 或者是5G技术导致了这种疾病 。
  • 关于有影响力人士的谣言:例如比尔·盖茨和福西博士代表制药公司策划了冠状病毒 。
  • 应对人们的恐惧:例如梅林达·盖茨基金会和约翰·霍普金斯大学在三个月前通过Event 201预测了冠状病毒 。
从我们的数据来看 , 真实和虚假新闻内容之间的一个明显区别是 , 虚假新闻似乎更多地使用了人的名字 , 这表明虚假新闻可能更加个性化 。
naturalnews.com vs orthomolecular.org以上两个新闻来源都提倡阴谋论 , 但是它们却关注不同的主题 。
1. naturalnews_bigram = get_top_n_bigram(df.loc[df['source'] == 'https://www.naturalnews.com/']['text'], 20)2. for word, freq in naturalnews_bigram:3.print(word, freq)natural_bigram.py
附代码 基于NLP的COVID-19虚假新闻检测

文章插图
 
naturalnews.com一直在传播虚假信息 , 例如在中国实验室将冠状病毒设计为生物武器 , 并且/或者传播病毒来掩盖暴露于5G无线技术有关有害健康的影响 。


推荐阅读