Sumit Raj
Building Chatbots with Python Using Natural Language Processing and Machine Learning
Sumit Raj
Bangalore, Karnataka, India
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-4095-3 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4095-3 e-ISBN 978-1-4842-4096-0
https://doi.org/10.1007/978-1-4842-4096-0
Library of Congress Control Number: 2018965181
Sumit Raj 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
I want to dedicate this book and all the hard work to achieve this feat to my elder brother, Nikhil Raj, whom I lost this year. I cant seem to imagine how proud he would have been seeing his brothers book being published today.
I would like to thank my parents Dinanath Prasad and Shobha Gupta, my brother and sister, relatives, and all my dearest friends who always supported & encouraged me and pardoned my absence at times during the write-up of this book.
Introduction
This book has been written with immense care to keep the teachings from this book very pragmatic and results-oriented. Building chatbots is not just about completing a tutorial or following a few stepsits a skill in itself. This book will certainly not bore you with lots of text and process to be read; rather, it takes the learning-by-doing approach. You must have used at least one chatbot to do something in your life by now. Whether you are a programmer or not, once you go through this book you will find the building blocks of chatbots, and all the mysteries will be uncovered. Building chatbots may seem difficult from the outside, but this book makes it so easy for you. Our brain is not designed to directly process the complex concepts; rather, we learn step-by-step. When you are reading this book, from the first chapter through the last chapter, you will find how clearly things are progressing. Although you can directly go to any chapter, I highly recommend you start from the first chapter, as it is bound to bolster your thoughts.
This book is like a web series where you wont be able to resist the next chapter after completing one. Any chatbot that you interact with after going through this book will create a picture in your mind on how that chatbot is designed and built internally.
Who This Book Is For
This book will serve as a great resource for learning the concepts related to chatbots and learning how to build them. Those who will find this book useful include:
Python web developers looking to expand their knowledge or career into chatbots development
Students and aspiring programmers wanting to acquire a new skill set by hands-on experience to showcase something and stand out in the crowd
Natural Language enthusiasts looking to learn how to build a chatbot from scratch
Budding entrepreneurs with a great idea but not enough technical feasibility information on how to go about making a chatbot
Product/Engineering managers planning for a chatbot-related project
How Do I Approach This Book?
Remember this book is not written like other books are written. This book is written keeping in mind that once you are done with this book, you can build a chatbot yourself or teach someone how to build a chatbot. Its very important to keep a few points in mind before approaching this book like any other book:
This book covers almost everything that you need to build a chatbot, rather than what exists.
This book is about spending more time in doing things on your system, with this book by your side. Make sure you execute each code snippet and try to write the code; do not copy and paste.
Make sure you follow the steps as they appear in the book; dont worry if you dont understand something. You will get to know about that later in the chapter.
Use the source code and Jupyter Notebook provided with this book for your reference.
What Will You Learn in This Book?
Chapter: The Beloved Chatbots In this chapter you will get to know about things related to chatbots from both a business and developers perspective. This chapter sets the tone for getting our hands dirty with chatbots concepts and converting them into code. Hopefully, you will have a reason why you should definitely build a chatbot for yourself or your company by the end of this chapter.
Chapter: Natural Language Processing for Chatbots In this chapter you will learn about what tools and methods to use when NLP is needed for chatbots. This chapter not only teaches you about the method in NLP but also takes real-life examples and demonstrates with coding examples. This chapter also discusses why a particular NLP method may be needed in chatbots. Note that NLP in itself is a skill to have.
Chapter: Building Chatbots the Easy Way In this chapter you will learn about building a chatbot in a nice and easy manner using tools like Dialogflow. If you are a non-programmer, you will surely like it, as it requires little or no programming skills.
Chapter: Building Chatbots the Hard Way In this chapter, you will learn about building chatbots in a manner that people want to build. The title says the hard way, but once you have completed the previous chapter, you will be wanting more, as this chapter will teach how to build chatbots in-house from scratch and how to train chatbots using machine learning algorithms.