-
Notifications
You must be signed in to change notification settings - Fork 0
API docs
In this page, more detail will be provided about each of the six classes in the library along with their individual methods. For a quick start, you can head over to Get started and for examples using each of these classes, you can head over to Examples
This is the main class in the CleanTweet library, it is the class for cleaning and other preprocessing techniques for the attached text document. The class currently has three methods: clean(), show_word_collocations(), and remove_curse_words(). This class will be the home for all preprocessing techniques that involves transforming the .txt document for easier feature engineering in the Natural Language Processing (NLP) task pipeline.
parameters:
tokenize_method: if set to True, it wil sentence tokenize else it will word tokenize. The default is word tokenize.
return: the word tokens as a string.
return: a list of the word collocations.
remove_curse_words(): method to remove curse words like 'fuck', 'hell', and 'damn' from the .txt document.
return: a list of appropriate words in the text/corpus.
The class housing the different methods for creating NLP diagrams/charts for easy analysis and visual inference. This class is built ontop of both NLTK and Matplotlib and acts as an easy wrapper whereby in using the previous two libraries only, you'll need 5 or sometimes ten lines of code, using this class in some instances you'll need only 1 or 2 lines of code.
parameters:
width: the width of the wordcloud, default is 1400px
height: the height of the wordcloud, default is 800px
max_words: how many words do you want to appear in the wordcloud, default is 100
background_color: the background color of the wordcloud. You can enter the colors or hex codes as a string
args: you can pass any other argument that is expected of the Wordcloud library method; as this method is a wrapper for that.
return: a wordcloud display image
frequency_distribution(): method for showing the frequency distribution (amount of times a particular word occurs) in the text/document.
parameters:
amount: how many words do you want to know their frequency amount? the default is 2. The argument must be an integer and not a float
value.
return: a frequency distribution image.
parameters:
word_amount: amount of words whose frequencies you want to see; default is 2.
return: a horizontal table showing the related words and their corresponding frequencies.
bar_chart(): a method for showing the bar chart with the word on the x-axis and their frequencies on the y-axis
parameters:
amount_of_bars: the amount of bars to show in the bar chart; default value is 10 and maximum is 20. It's advisable to keep it below
15 for pleasing visual results.
bar_color: the color of the bars you want. It should be a string of either html color value names, or a valid color hex code.
background_color: change the background color of the bar chart, the default value is lightgray.
xlabel_name: the name of the xlabel, must be a string. The default value is Word.
ylabel_name: the name of the ylabel, must be a string. The default value is Frequency
title: the title of the bar graph, to add a title, pass a string as an argument.
x_ticks_rotation: the angle you want the xticks to be in, default is 90 degrees.
grid_color: the grid color you want, it must be a string.
grid_alpha: how much transparency do you want, default is 0.1. it must be a floating point value. e.g. 0.1, 0.2 etc. if unsure, leave
as it is.
return: a bar chart of the most frequent words in the document.