python nltk 库_使用python和nltk库进行情感分析

python nltk 库

我们将如何做呢? (How are we going to be doing this ?)

Python, being Python, apart from its incredible readability, has some remarkable libraries at hand. One of which, is NLTK. NLTK or Natural Language Tool Kit is one of the best Python NLP libraries out there. The functionality it leaves at your fingertips while maintaining its ease of use and again, readability is just fantastic.

Python是Python,除了具有令人难以置信的可读性外,还有一些出色的库。 其中之一是NLTK。 NLTK或自然语言工具包是目前最好的Python NLP库之一。 在保持其易用性的同时,它的功能触手可及,而且可读性同样出色。

In fact, we’re going to be completing this mini project under 25 lines of code. And you’re most probably going to understand each line as you read through it. Crazy, I know.

实际上,我们将用25行代码完成这个小型项目。 阅读完每一行后,您很可能会理解每一行。 疯狂,我知道。

让我们开始吧! (Let’s get right into it !)

  1. IDE

    集成开发环境

Personally whenever I’m doing anything even relatively fancy, in Python, I use Jupyter Lab. Being able to see what each line does makes it really easy to debug and it’s also strangely therapeutic. Shrugs.

就个人而言,无论何时我想做的事甚至都比较花哨,在Python中,我都使用Jupyter Lab 。 能够看到每条线的功能使得调试起来非常容易,而且也很奇怪。 耸耸肩。

Image for post
Jupyter Lab
Jupyter实验室

But you’re free to use whatever you want. It’s a free world. Mostly.

但是您可以随意使用任何内容。 这是一个自由的世界。 大多。

2. Dependencies

2. 依存关系

Now, we’ve got to get hold of the libraries we need. Just 4, super easy to get libraries.

现在,我们必须掌握所需的库。 仅需4个,超级容易获得库。

  1. NLTK

    NLTK
  2. Numpy

    脾气暴躁的
  3. Pandas

    大熊猫
  4. Scikit-learn

    Scikit学习

To install NLTK, run the following in the terminal

安装NLTK ,请在终端中运行以下命令

pip install nltk

To install Numpy, run the following in the terminal

安装Numpy ,请在终端中运行以下命令

pip install numpy

To install Pandas, run the following in the terminal

安装Pandas ,请在终端中运行以下命令

pip install pandas

To install Scikit-learn, run the following in the terminal

安装Scikit-learn ,请在终端中运行以下命令

pip install scikit-learn

So intuitive. I mean, come on, it really can’t get any easier.

如此直观。 我的意思是,拜托,这真的很难。

编码时间 (Time to code)

Image for post

First things first. Let’s import NLTK.

首先是第一件事。 让我们导入NLTK。

import NLTK 

Now, there’s a slight hitch. I did say 4 dependencies, didn’t I ? Ok, here’s the last one, I swea

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值