As described in [1], natural language processing (NLP) is a common research subfield shared by many research fields such as linguistics, computer science, information engineering, and artificial intelligence, etc. NLP is concerned with the interactions between computers and human natural languages in general and in particular how to use computers to process and analyze natural language data (e.g., text, voice, etc.). Some of the major challenges in NLP include speech recognition, natural language understanding (e.g., text understanding), and natural language generation.

One of the early applications of machine learning in text understanding is email and message spam detection [1]. With the advancement of deep learning, many new advanced language understanding methods have been published such as the deep learning method BERT (see [2] for an example of using MobileBERT for question and answer).

The other popular method in NLP is Named Entity Recognition (NER). The main purpose of NER is to extract named entities (e.g., personal names, organization names, location names, product names, etc.) from unstructured text. There are many open source NLP libraries/tools with NER support such as NLTK and SpaCy [3]. Recently Spark NLP [4] gets more and more attention due to its more complete list of supported NLP features [5][6].

It seems to me that the development of Spark NLP [4] is based on Ubuntu Linux and OpenJDK. Thus it’s straight forward to setup environment for Spark NLP in Colab (see instructions and code examples) since Colab uses Ubuntu operating system. However, I noticed that it’s difficult to set up a local environment on Mac for Spark NLP due to the following known exception:

Image for post

To avoid the problem, this article demonstrates how to set up a Docker environment [7] to run Spark NLP for NER and other NLP features in a Docker container. Such a Docker environment can serve as a basis for establishing a Spark NLP microservices platform.

1. Introduction to Docker

As described in [7], Docker is a tool that allows us to easily deploy applications (e.g., Spark NLP) in a sandbox (called container) to run on any Docker supported host operating system (i.e., Mac).

The basic concepts of Docker are:

  • Dockerfile:
  • Docker image
  • Docker container
1.1 Dockerfile

Dockerfile [7] is a simple text file that contains a list of commands (similar to Linux commands) for creating a Docker image. It’s a way to automate the Docker image creation process.

1.2 Docker Image

docker image [7] is a read-only template that contains a set of instructions for creating a Docker container that can run on the Docker platform. It provides a convenient way to package up applications and preconfigured server environments.

A Docker image is built from a Dockerfile.

#spark #ner #towards-data-science #nlp #docker

Running Spark NLP in Docker Container for Named Entity Recognition
11.45 GEEK