rahul verma
rahul verma

Reputation: 1

NLTK TweetTokennizer is not workin on google colab notebook

I have downloaded all the packages of NLTK with the command of nltk.download(). but the thing is that when I try to import TweetTokenizer I get the error.

tokenizer = TweetTokenizer(preserve_case=False, strip_handles=True, reduce_len=True)
tweet_tokens = tokenizer.tokenize(tweet2)

Error:

NameError: name 'TweetTokenizer' is not defined

Upvotes: 0

Views: 513

Answers (2)

Akshay Sehgal
Akshay Sehgal

Reputation: 19307

nltk.download() is not for importing packages but for downloading respective corpora and modules. Details found here.

You still have to import the modules. For this you will have to use from nltk.tokenize import TweetTokenizer. Details found here.

Upvotes: 1

sophros
sophros

Reputation: 16738

You have probably not imported the TweetTokenizer. Try:

from nltk.tokenize import TweetTokenizer

Upvotes: 0

Related Questions