Natural Language Processing with Spark NLP

Book description

If you want to build an enterprise-quality application that uses natural language text but aren’t sure where to begin or what tools to use, this practical guide will help get you started. Alex Thomas, principal data scientist at Wisecube, shows software engineers and data scientists how to build scalable natural language processing (NLP) applications using deep learning and the Apache Spark NLP library.

Through concrete examples, practical and theoretical explanations, and hands-on exercises for using NLP on the Spark processing framework, this book teaches you everything from basic linguistics and writing systems to sentiment analysis and search engines. You’ll also explore special concerns for developing text-based applications, such as performance.

In four sections, you’ll learn NLP basics and building blocks before diving into application and system building:

  • Basics: Understand the fundamentals of natural language processing, NLP on Apache Stark, and deep learning
  • Building blocks: Learn techniques for building NLP applications—including tokenization, sentence segmentation, and named-entity recognition—and discover how and why they work
  • Applications: Explore the design, development, and experimentation process for building your own NLP applications
  • Building NLP systems: Consider options for productionizing and deploying NLP models, including which human languages to support

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Why Natural Language Processing Is Important and Difficult
    2. Background
    3. Philosophy
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Online Learning
    7. How to Contact Us
    8. Acknowledgments
  2. I. Basics
  3. 1. Getting Started
    1. Introduction
    2. Other Tools
    3. Setting Up Your Environment
      1. Prerequisites
      2. Starting Apache Spark
      3. Checking Out the Code
    4. Getting Familiar with Apache Spark
      1. Starting Apache Spark with Spark NLP
      2. Loading and Viewing Data in Apache Spark
    5. Hello World with Spark NLP
  4. 2. Natural Language Basics
    1. What Is Natural Language?
      1. Origins of Language
      2. Spoken Language Versus Written Language
    2. Linguistics
      1. Phonetics and Phonology
      2. Morphology
      3. Syntax
      4. Semantics
    3. Sociolinguistics: Dialects, Registers, and Other Varieties
      1. Formality
      2. Context
    4. Pragmatics
      1. Roman Jakobson
      2. How To Use Pragmatics
    5. Writing Systems
      1. Origins
      2. Alphabets
      3. Abjads
      4. Abugidas
      5. Syllabaries
      6. Logographs
    6. Encodings
      1. ASCII
      2. Unicode
      3. UTF-8
    7. Exercises: Tokenizing
      1. Tokenize English
      2. Tokenize Greek
      3. Tokenize Ge’ez (Amharic)
    8. Resources
  5. 3. NLP on Apache Spark
    1. Parallelism, Concurrency, Distributing Computation
      1. Parallelization Before Apache Hadoop
      2. MapReduce and Apache Hadoop
      3. Apache Spark
    2. Architecture of Apache Spark
      1. Physical Architecture
      2. Logical Architecture
    3. Spark SQL and Spark MLlib
      1. Transformers
      2. Estimators and Models
      3. Evaluators
    4. NLP Libraries
      1. Functionality Libraries
      2. Annotation Libraries
      3. NLP in Other Libraries
    5. Spark NLP
      1. Annotation Library
      2. Stages
      3. Pretrained Pipelines
      4. Finisher
    6. Exercises: Build a Topic Model
    7. Resources
  6. 4. Deep Learning Basics
    1. Gradient Descent
    2. Backpropagation
    3. Convolutional Neural Networks
      1. Filters
      2. Pooling
    4. Recurrent Neural Networks
      1. Backpropagation Through Time
      2. Elman Nets
      3. LSTMs
    5. Exercise 1
    6. Exercise 2
    7. Resources
  7. II. Building Blocks
  8. 5. Processing Words
    1. Tokenization
    2. Vocabulary Reduction
      1. Stemming
      2. Lemmatization
      3. Stemming Versus Lemmatization
      4. Spelling Correction
      5. Normalization
    3. Bag-of-Words
    4. CountVectorizer
    5. N-Gram
    6. Visualizing: Word and Document Distributions
    7. Exercises
    8. Resources
  9. 6. Information Retrieval
    1. Inverted Indices
      1. Building an Inverted Index
    2. Vector Space Model
      1. Stop-Word Removal
      2. Inverse Document Frequency
      3. In Spark
    3. Exercises
    4. Resources
  10. 7. Classification and Regression
    1. Bag-of-Words Features
    2. Regular Expression Features
    3. Feature Selection
    4. Modeling
      1. Naïve Bayes
      2. Linear Models
      3. Decision/Regression Trees
      4. Deep Learning Algorithms
    5. Iteration
    6. Exercises
  11. 8. Sequence Modeling with Keras
    1. Sentence Segmentation
      1. (Hidden) Markov Models
    2. Section Segmentation
    3. Part-of-Speech Tagging
    4. Conditional Random Field
    5. Chunking and Syntactic Parsing
    6. Language Models
    7. Recurrent Neural Networks
    8. Exercise: Character N-Grams
    9. Exercise: Word Language Model
    10. Resources
  12. 9. Information Extraction
    1. Named-Entity Recognition
    2. Coreference Resolution
    3. Assertion Status Detection
    4. Relationship Extraction
    5. Summary
    6. Exercises
  13. 10. Topic Modeling
    1. K-Means
    2. Latent Semantic Indexing
    3. Nonnegative Matrix Factorization
    4. Latent Dirichlet Allocation
    5. Exercises
  14. 11. Word Embeddings
    1. Word2vec
    2. GloVe
    3. fastText
    4. Transformers
    5. ELMo, BERT, and XLNet
    6. doc2vec
    7. Exercises
  15. III. Applications
  16. 12. Sentiment Analysis and Emotion Detection
    1. Problem Statement and Constraints
    2. Plan the Project
    3. Design the Solution
    4. Implement the Solution
    5. Test and Measure the Solution
      1. Business Metrics
      2. Model-Centric Metrics
      3. Infrastructure Metrics
      4. Process Metrics
      5. Offline Versus Online Model Measurement
    6. Review
      1. Initial Deployment
      2. Fallback Plans
      3. Next Steps
    7. Conclusion
  17. 13. Building Knowledge Bases
    1. Problem Statement and Constraints
    2. Plan the Project
    3. Design the Solution
    4. Implement the Solution
    5. Test and Measure the Solution
      1. Business Metrics
      2. Model-Centric Metrics
      3. Infrastructure Metrics
      4. Process Metrics
    6. Review
    7. Conclusion
  18. 14. Search Engine
    1. Problem Statement and Constraints
    2. Plan the Project
    3. Design the Solution
    4. Implement the Solution
    5. Test and Measure the Solution
      1. Business Metrics
      2. Model-Centric Metrics
    6. Review
    7. Conclusion
  19. 15. Chatbot
    1. Problem Statement and Constraints
    2. Plan the Project
    3. Design the Solution
    4. Implement the Solution
    5. Test and Measure the Solution
      1. Business Metrics
      2. Model-Centric Metrics
    6. Review
    7. Conclusion
  20. 16. Object Character Recognition
    1. Kinds of OCR Tasks
      1. Images of Printed Text and PDFs to Text
      2. Images of Handwritten Text to Text
      3. Images of Text in Environment to Text
      4. Images of Text to Target
      5. Note on Different Writing Systems
    2. Problem Statement and Constraints
    3. Plan the Project
    4. Implement the Solution
    5. Test and Measure the Solution
    6. Model-Centric Metrics
    7. Review
    8. Conclusion
  21. IV. Building NLP Systems
  22. 17. Supporting Multiple Languages
    1. Language Typology
    2. Scenario: Academic Paper Classification
    3. Text Processing in Different Languages
      1. Compound Words
      2. Morphological Complexity
    4. Transfer Learning and Multilingual Deep Learning
    5. Search Across Languages
    6. Checklist
    7. Conclusion
  23. 18. Human Labeling
    1. Guidelines
    2. Scenario: Academic Paper Classification
    3. Inter-Labeler Agreement
    4. Iterative Labeling
    5. Labeling Text
      1. Classification
      2. Tagging
    6. Checklist
    7. Conclusion
  24. 19. Productionizing NLP Applications
    1. Spark NLP Model Cache
    2. Spark NLP and TensorFlow Integration
      1. Spark Optimization Basics
      2. Design-Level Optimization
      3. Profiling Tools
      4. Monitoring
      5. Managing Data Resources
      6. Testing NLP-Based Applications
      7. Unit Tests
      8. Integration Tests
      9. Smoke and Sanity Tests
      10. Performance Tests
      11. Usability Tests
      12. Demoing NLP-Based Applications
    3. Checklists
      1. Model Deployment Checklist
      2. Scaling and Performance Checklist
      3. Testing Checklist
    4. Conclusion
  25. Glossary
  26. Index

Product information

  • Title: Natural Language Processing with Spark NLP
  • Author(s): Alex Thomas
  • Release date: June 2020
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492047766