python 情绪分析_借助Python进行情绪和情感分析

本文介绍了如何使用Python的nltk库进行情绪分析。文章详细阐述了下载nltk模块、使用collections模块计数、matplotlib库绘图的过程,并通过去除停用词、标记化文本以及应用vader库的SentimentIntensityAnalyzer计算文本情感。
摘要由CSDN通过智能技术生成

python 情绪分析

Modules to be used:

使用的模块:

nltk, collections, string and matplotlib modules.

nltkcollectionsstringmatplotlib模块。

nltk Module

nltk模块

The full form of nltk is "Natural Language Tool Kit". It is a module written in Python which works on the human language like what are the sentiments and emotions attached to it.

nltk的完整形式是“ 自然语言工具包” 。 这是一个用Python编写的模块,它可以处理人类语言上的情感和情感

How can we Download it?

我们如何下载它?

General Way: 
pip install nltk

Pycharm Users: 
Go to the project interpreter and install it.

Now after downloading this module, it does not mean that we can use its every package, for this we have to download its every package in this way,

现在,下载此模块后,并不意味着我们可以使用其所有软件包,为此,我们必须以这种方式下载其所有软件包,

  • Create a blank .py file and write this code in it,

    创建一个空白的.py文件并在其中写入此代码,

    # import the nltk module
    import nltk
    
    # write this command
    nltk.download()
    
    And, run the file
    
  • Now after running this file, the compiler will show you the interface like this,

    现在,运行该文件后,编译器将向您显示如下界面,

    NLTK Downloader
    ---------------------------------------------------------------------------
        d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
    ---------------------------------------------------------------------------
    
    Downloader> 
    Write d as we have to download the packages of nltk in it.
    After this:
    
    Download which package (l=list; x=cancel)?
      Identifier>
    
    Write all in this ass we have to Download all packages of nltk 
    in our system,and after pressing enter this will take some
  • 7
    点赞
  • 64
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值