0%

Get to grips with solving real-world NLP problems, such as dependency parsing, information extraction, topic modeling, and text data visualization

Key Features

  • Analyze varying complexities of text using popular Python packages such as NLTK, spaCy, sklearn, and gensim
  • Implement common and not-so-common linguistic processing tasks using Python libraries
  • Overcome the common challenges faced while implementing NLP pipelines

Book Description

Python is the most widely used language for natural language processing (NLP) thanks to its extensive tools and libraries for analyzing text and extracting computer-usable data. This book will take you through a range of techniques for text processing, from basics such as parsing the parts of speech to complex topics such as topic modeling, text classification, and visualization.

Starting with an overview of NLP, the book presents recipes for dividing text into sentences, stemming and lemmatization, removing stopwords, and parts of speech tagging to help you to prepare your data. You'll then learn ways of extracting and representing grammatical information, such as dependency parsing and anaphora resolution, discover different ways of representing the semantics using bag-of-words, TF-IDF, word embeddings, and BERT, and develop skills for text classification using keywords, SVMs, LSTMs, and other techniques. As you advance, you'll also see how to extract information from text, implement unsupervised and supervised techniques for topic modeling, and perform topic modeling of short texts, such as tweets. Additionally, the book shows you how to develop chatbots using NLTK and Rasa and visualize text data.

By the end of this NLP book, you'll have developed the skills to use a powerful set of tools for text processing.

What you will learn

  • Become well-versed with basic and advanced NLP techniques in Python
  • Represent grammatical information in text using spaCy, and semantic information using bag-of-words, TF-IDF, and word embeddings
  • Perform text classification using different methods, including SVMs and LSTMs
  • Explore different techniques for topic modeling such as K-means, LDA, NMF, and BERT
  • Work with visualization techniques such as NER and word clouds for different NLP tools
  • Build a basic chatbot using NLTK and Rasa
  • Extract information from text using regular expression techniques and statistical and deep learning tools

Who this book is for

This book is for data scientists and professionals who want to learn how to work with text. Intermediate knowledge of Python will help you to make the most out of this book. If you are an NLP practitioner, this book will serve as a code reference when working on your projects.

Table of Contents

  1. Python Natural Language Processing Cookbook
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Sections
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. There's more…
    12. See also
    13. Get in touch
    14. Reviews
  6. Chapter 1: Learning NLP Basics
    1. Technical requirements
    2. Dividing text into sentences
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. There's more…
    7. See also
    8. Dividing sentences into words – tokenization
    9. Getting ready
    10. How to do it…
    11. How it works…
    12. There's more…
    13. See also
    14. Parts of speech tagging
    15. Getting ready
    16. How to do it…
    17. How it works…
    18. There's more…
    19. See also
    20. Word stemming
    21. Getting ready
    22. How to do it…
    23. How it works…
    24. There's more…
    25. See also
    26. Combining similar words – lemmatization
    27. Getting ready
    28. How to do it…
    29. How it works…
    30. There's more…
    31. Removing stopwords
    32. Getting ready…
    33. How to do it…
    34. How it works…
    35. There's more…
  7. Chapter 2: Playing with Grammar
    1. Technical requirements
    2. Counting nouns – plural and singular nouns
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. There's more…
    7. Getting the dependency parse
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. See also
    12. Splitting sentences into clauses
    13. Getting ready
    14. How to do it…
    15. How it works…
    16. Extracting noun chunks
    17. Getting ready
    18. How to do it…
    19. How it works…
    20. There's more…
    21. See also
    22. Extracting entities and relations
    23. Getting ready
    24. How to do it…
    25. How it works…
    26. There's more…
    27. Extracting subjects and objects of the sentence
    28. Getting ready
    29. How to do it…
    30. How it works…
    31. There's more…
    32. Finding references – anaphora resolution
    33. Getting ready
    34. How to do it…
    35. How it works…
    36. There's more…
  8. Chapter 3: Representing Text – Capturing Semantics
    1. Technical requirements
    2. Putting documents into a bag of words
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. There's more…
    7. Constructing the N-gram model
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. There's more…
    12. Representing texts with TF-IDF
    13. Getting ready
    14. How to do it…
    15. How it works…
    16. There's more…
    17. Using word embeddings
    18. Getting ready
    19. How to do it…
    20. How it works…
    21. There's more…
    22. See also
    23. Training your own embeddings model
    24. Getting ready
    25. How to do it…
    26. How it works…
    27. There's more…
    28. See also
    29. Representing phrases – phrase2vec
    30. Getting ready
    31. How to do it…
    32. How it works…
    33. See also
    34. Using BERT instead of word embeddings
    35. Getting ready
    36. How to do it…
    37. How it works…
    38. Getting started with semantic search
    39. Getting ready
    40. How to do it…
    41. How it works…
    42. See also
  9. Chapter 4: Classifying Texts
    1. Technical requirements
    2. Getting the dataset and evaluation baseline ready
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. Performing rule-based text classification using keywords
    7. Getting ready
    8. How to do it…
    9. How it works…
    10. There's more…
    11. Clustering sentences using K-means – unsupervised text classification
    12. Getting ready
    13. How to do it…
    14. How it works…
    15. Using SVMs for supervised text classification
    16. Getting ready
    17. How to do it…
    18. How it works…
    19. There's more…
    20. Using LSTMs for supervised text classification
    21. Getting ready
    22. How to do it…
    23. How it works…
  10. Chapter 5: Getting Started with Information Extraction
    1. Technical requirements
    2. Using regular expressions
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. There's more…
    7. Finding similar strings: the Levenshtein distance
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. There's more…
    12. See also
    13. Performing named entity recognition using spaCy
    14. Getting ready
    15. How to do it…
    16. How it works…
    17. There's more…
    18. Training your own NER model with spaCy
    19. Getting ready
    20. How to do it…
    21. How it works…
    22. There's more…
    23. See also
    24. Discovering sentiment analysis
    25. Getting ready
    26. How to do it…
    27. How it works…
    28. Sentiment for short texts using LSTM: Twitter
    29. Getting ready
    30. How to do it…
    31. How it works…
    32. Using BERT for sentiment analysis
    33. Getting ready
    34. How to do it…
    35. How it works…
    36. There's more…
    37. See also
  11. Chapter 6: Topic Modeling
    1. Technical requirements
    2. LDA topic modeling with sklearn
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. There's more…
    7. LDA topic modeling with gensim
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. There's more…
    12. NMF topic modeling
    13. Getting ready
    14. How to do it…
    15. How it works…
    16. K-means topic modeling with BERT
    17. Getting ready
    18. How to do it…
    19. How it works…
    20. Topic modeling of short texts
    21. Getting ready
    22. How to do it…
    23. How it works…
    24. See also
  12. Chapter 7: Building Chatbots
    1. Technical requirements
    2. Building a basic chatbot with keyword matching
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. There's more…
    7. Building a basic Rasa chatbot
    8. Getting ready
    9. How to do it…
    10. How it works…
    11. There's more…
    12. See also
    13. Creating question-answer pairs with Rasa
    14. Getting ready
    15. How to do it…
    16. How it works…
    17. Creating and visualizing conversation paths with Rasa
    18. Getting ready
    19. How to do it…
    20. How it works…
    21. Creating actions for the Rasa chatbot
    22. Getting ready
    23. How to do it…
    24. How it works…
    25. See also
  13. Chapter 8: Visualizing Text Data
    1. Technical requirements
    2. Visualizing the dependency parse
    3. Getting ready
    4. How to do it…
    5. How it works…
    6. Visualizing parts of speech
    7. Getting ready
    8. How to do it…
    9. How it works…
    10. Visualizing NER
    11. Getting ready
    12. How to do it…
    13. How it works…
    14. Constructing word clouds
    15. Getting ready
    16. How to do it…
    17. How it works…
    18. There's more…
    19. See also
    20. Visualizing topics
    21. Getting ready
    22. How to do it…
    23. How it works…
    24. See also
    25. Why subscribe?
  14. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think
18.188.40.207