-
Notifications
You must be signed in to change notification settings - Fork 0
Examples
In this short example, we will be looking at cleaning a body of text mined from an API, to prepare your text for further processing and feature engineering like Sentiment Analysis etc. With cleantweet, it is easy to clean a body of text with just a few lines of code:
!pip install cleantweet
import cleantweet as clt
data = clt.CleanTweet('mini corpus for testing')
data = data.clean()
print(data)
You can use the DiagramTweet class to create different diagrams for NLP tasks. To create a Wordcloud using cleantweet, takes two lines of code:
figures = clt.DiagramTweet('mini corpus for testing.txt')
figures.word_cloud()
The first line creates an instance of the DiagramTweet class and the second line calls the word_cloud() method. To know more about the different [parameters of the word_cloud() method, you can see it's full definition in the API docs

The DiagramTweet class has several methods for creating diagrams that can be used to visualize the textual statistics in your corpus. One of them is the Frequency Distribution chart; this chart shows you how frequent each word appears in your text. Creating a frequency distribution with cleantweet is just two lines of code:
figures = clt.DiagramTweet('mini corpus for testing.txt')
figures.frequency_distribution(20)
The first line creates an instance of the DiagramTweet class and the second line calls the frequency_distribution() method. To know more about the different [parameters of the frequency_distribution() method, you can see it's full definition in the API docs
