Skip to content

Get started

lare edited this page Jan 13, 2025 · 7 revisions

Get started

To get started using CleanTweet, you first need to install it on your IDE, assuming you're using Google Colab:

!pip install cleantweet

Then import the library:

import cleantweet as clt

'clt' is the gentleman's agreement on the alias to use with CleanTweet but you're free to use a different alias.

Once you've imported the library, you can have access to its over 100 methods and 6 classes; lets do a simple task of cleaning textual data mined from the X's API:

data = clt.CleanTweet('sample_text.txt')
data = data.clean()
print(data)

In the first line, we create an instance of the CleanTweet class so we can access it's clean() method, note that the CleanTweet class has a required parameter called 'text' - you must pass in the path to a .txt file else it would throw off an error.

For the second line, we call the clean() method on the CleanTweet instance which is called 'data', then for the last line we print out the results. The result should be a string of text that has been cleaned and ready for any other Natural Language Processing tasks.

Clone this wiki locally