...

/

Types of Irrelevant Text Data

Types of Irrelevant Text Data

Learn about different types of irrelevant text data.

Introduction

Irrelevant text data refers to words, phrases, or sentences in the larger text context that are unimportant during analysis. This makes dealing with irrelevant text data an essential step in text preprocessing. It can improve the accuracy and efficiency of NLP tasks, such as sentiment analysis, topic modeling, and document classification. In the following sections, we’ll look at some examples of irrelevant text data and how to remove them using various NLP libraries.

Stopwords

In the introductory chapter of this course, we defined what stopwords are. These are common words that don’t carry much meaning or contribute to understanding the text. Let’s practice removing them using the NLTK library.

Press + to interact
Python 3.8
Files

Let’s review the code line by line:

  • Lines 1–5: We import the nltk library for NLP, the pandas library, and stopwords from the corpus module in the NLTK library. We download the stopwords corpus and set quiet=True so we don’t get an installation message in the output. Later, we create a set of English stopwords.

  • Line 7: We read the CSV file named reviews.csv and store its content in a DataFrame called df. ...