Book Image

Hands-On Python Natural Language Processing

By : Aman Kedia, Mayank Rasu
Book Image

Hands-On Python Natural Language Processing

By: Aman Kedia, Mayank Rasu

Overview of this book

Natural Language Processing (NLP) is the subfield in computational linguistics that enables computers to understand, process, and analyze text. This book caters to the unmet demand for hands-on training of NLP concepts and provides exposure to real-world applications along with a solid theoretical grounding. This book starts by introducing you to the field of NLP and its applications, along with the modern Python libraries that you'll use to build your NLP-powered apps. With the help of practical examples, you’ll learn how to build reasonably sophisticated NLP applications, and cover various methodologies and challenges in deploying NLP applications in the real world. You'll cover key NLP tasks such as text classification, semantic embedding, sentiment analysis, machine translation, and developing a chatbot using machine learning and deep learning techniques. The book will also help you discover how machine learning techniques play a vital role in making your linguistic apps smart. Every chapter is accompanied by examples of real-world applications to help you build impressive NLP applications of your own. By the end of this NLP book, you’ll be able to work with language data, use machine learning to identify patterns in text, and get acquainted with the advancements in NLP.
Table of Contents (16 chapters)
1
Section 1: Introduction
4
Section 2: Natural Language Representation and Mathematics
9
Section 3: NLP and Learning

Detecting sarcasm in text using CNNs

The convolutions that we have seen so far capture spatial relations in data as specific images. However, text has more of a sequential relationship, where words in the vicinity of a given account for more information for that particular word rather than any word appearing in a line right above them. Hence, for text data, we look at one-dimensional spatial relationships and leverage the Conv1D layer for this purpose. This is similar to going through n-grams, wherein there would be overlaps in consecutive n-gram windows. The value of n would be specified by the kernel size parameter you provide as input to the Conv1D layer.

The following diagram will help us understand how CNNs can be used to find patterns in text data:

This image has been sourced from the paper, Convolutional Neural Networks for Sentence Classification by Yoon Kim, which was released in 2014

The preceding diagram shows how word embeddings are sent across as inputs to the convolutional...