Applications and Use Cases of Natural Language Processing (NLP)
Main takeaways
- NLP applications turn unstructured language into information or actions that software can classify, retrieve, analyze, or use in workflows.
- Common enterprise use cases include customer support, service desk automation, voice assistants, business intelligence, sentiment analysis, healthcare, research, and SEO.
- Modern NLP applications can combine techniques such as intent detection, named entity recognition, semantic retrieval, embeddings, and Transformers depending on the task.
Introduction
Natural language processing becomes most useful when language is connected to a specific task, such as interpreting a voice command, extracting clinical information, or analyzing customer sentiment.
Across these applications, NLP converts unstructured human language into signals, structured information, or outputs that software can use.
In this article, we will explore common NLP applications across enterprise and domain-specific settings. We then implement sentiment analysis in Python using the Rotten Tomatoes dataset and a pretrained Transformer model.
Real-world applications and industry use cases
Across industries, NLP serves the same core function of converting human language into signals that software can classify, retrieve, analyze, or act on. What changes across applications is the language source, domain knowledge, and downstream task.
Enterprise applications: support, voice assistants, and business operations
NLP commonly converts unstructured inputs such as conversations, support tickets, voice commands, and business questions into structured information or actions that operational systems can process.
How chatbots use natural language processing in support
Support chatbots use NLP to detect intent, extract entities, retrieve relevant information, and generate or select responses. For example, a billing query can be classified by issue type, linked to the customer’s account or contract, and routed to the appropriate workflow using a combination of NER, semantic retrieval, knowledge sources, and language models.
How does natural language processing work in service desk software?
NLP helps service desk software convert free-text tickets into structured operational data. It can classify requests, identify affected systems, detect urgency, summarize ticket histories, retrieve similar incidents or knowledge-base articles, and automatically route tickets to the appropriate team.
How is natural language processing used in voice assistance?
Voice assistants convert speech into text, then use NLP to identify intent, entities, and context and determine the appropriate response or action. The response can then be converted back into speech, enabling IVR systems and smart-home assistants to handle spoken requests.
How is NLP used in business intelligence?
NLP enables users to query business data using natural language instead of structured queries. For example, SAP Analytics Cloud’s Just Ask interprets business questions and returns relevant results or visualizations based on the underlying data model.
Sentiment analysis and opinion mining
Sentiment analysis is an NLP application and a form of opinion mining that identifies opinions or emotions in text, typically classifying sentiment as positive, negative, or neutral. Organizations use it to analyze customer reviews, surveys, support conversations, and social media posts at scale.
Basic sentiment analysis can use lexicon-based methods that assign sentiment scores to words. Modern systems use embeddings and Transformers to better interpret polarity, intent, emotion, negation, and context.
Semantic search and enterprise knowledge retrieval
NLP helps search systems interpret the meaning and intent behind a query rather than relying only on exact keyword matches. Embeddings, entity recognition, and semantic search can connect a user’s question with relevant documents, concepts, and entities even when the query and source content use different terminology.
Machine Translation and Localization
Machine translation systems use NLP models to map text from one language to another while preserving meaning, context, and grammatical structure. Modern multilingual Transformers can model relationships across languages, enabling applications such as website localization, multilingual customer support, and cross-language information access.
Domain-specific NLP: healthcare, research, legal, and digital marketing
Domain-specific NLP adapts language processing to specialized terminology, document structures, and task requirements. In healthcare, biomedical research, and digital marketing, this allows organizations to extract structured signals from text that general-purpose language processing may not represent precisely enough.
What is natural language processing in healthcare?
Healthcare NLP extracts clinical information from unstructured electronic health records (EHRs), physician notes, discharge summaries, and medical reports. Systems can identify diagnoses, medications, symptoms, procedures, and temporal relationships. They then normalize these mentions against clinical terminologies for downstream search, analytics, or decision-support workflows.
How is natural language processing used in biomedical research?
Biomedical researchers use NLP to process large volumes of scientific literature and extract entities and relationships involving genes, proteins, diseases, drugs, and treatments. These techniques can support literature screening and systematic reviews by identifying relevant studies, classifying abstracts, and structuring evidence that would otherwise require extensive manual review.
How to use natural language processing for SEO
NLP can support SEO by analyzing how terms, entities, and topics occur across search queries, competitor content, and a website’s existing pages. Embeddings and semantic clustering can group related keywords by context and search intent, helping content teams identify topic clusters, coverage gaps, and semantically related concepts.
How is NLP used in legal and compliance workflows?
Legal and compliance teams can use NLP to analyze contracts, policies, regulations, and other large document collections. NLP systems can identify clauses, entities, obligations, dates, and relationships, helping teams search documents, compare provisions, extract structured information, and flag content for further review.
Practical sentiment analysis in Python: A step-by-step guide
The workflow moves from raw movie-review data to model predictions that can be evaluated against the dataset labels. Workflows contain four key stages:
- Select the NLP libraries: Python provides different libraries at different abstraction levels. NLTK supports foundational text-processing and linguistic operations, spaCy provides production-oriented tokenization, parsing, NER, and pipelines. And Hugging Face Transformers provides pretrained transformer models and tokenizers. Similarly, PyTorch provides tensor operations, neural-network components, training loops, and GPU execution used to build or fine-tune neural NLP models.
- Clean and tokenize the input: Raw text is normalized and segmented into units the model can process. For example, with spaCy, spacy.load(“en_core_web_sm”) loads an English processing pipeline that can perform tokenization alongside linguistic operations such as part-of-speech tagging, dependency parsing, and NER.
- Generate features or embeddings: The processed text is converted into numerical representations. Traditional NLP may use features such as TF-IDF or n-grams, while neural NLP commonly uses dense word, sentence, or contextual embeddings generated by pretrained models.
- Run inference and evaluate the output: The representation is passed to a classifier, sequence model, transformer, or other task-specific component to generate predictions. Evaluation then depends on the task. For instance, classification may use precision, recall, and F1. NER can use entity-level precision, recall, and F1, and retrieval systems may use metrics such as Recall@K or Mean Reciprocal Rank (MRR).
How to do natural language processing in Python: developer quickstart
The following example shows how to implement natural language processing in Python using spaCy, Hugging Face Transformers, and scikit-learn. We build a sentiment analysis workflow using the Rotten Tomatoes dataset, covering text preprocessing, pretrained model inference, and evaluation.
Step 1: Install and import the NLP libraries
Start by installing the libraries required for data loading, preprocessing, model inference, and evaluation:
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Install the libraries used in this NLP workflow</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>!pip install datasets transformers torch spacy scikit-learn --quiet</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Download spaCy's small English language model</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>!python -m spacy download en_core_web_sm --quiet</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>
Then import the required packages:
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># import the packages</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>import spacy</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>import torch</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>from datasets import load_dataset</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>from transformers import pipeline</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>from sklearn.metrics import accuracy_score, classification_report</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print("All libraries loaded ✅")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>
Step 2: Load the rotten tomatoes dataset
We use the Rotten Tomatoes dataset from Hugging Face, where each movie review is labeled as positive (1) or negative (0). We select 20 examples to keep the demonstration small and fast.
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Load the test split of the Rotten Tomatoes dataset</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>dataset = load_dataset(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> "cornell-movie-review-data/rotten_tomatoes",</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> split="test"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Shuffle the data reproducibly and select 20 reviews</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>sample = dataset.shuffle(seed=42).select(range(20))</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Inspect the dataset and selected sample</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(f"Dataset size: {len(dataset)} reviews")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(f"Sample size : {len(sample)} reviews")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(f"Columns : {sample.column_names}")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print()</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Preview the first three reviews and their labels</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>for i in range(3):</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> label = "Positive" if sample[i]["label"] == 1 else "Negative"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> print(f"[{label:>8}] {sample[i]['text'][:80]}...")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>
load_dataset() downloads the test split, while shuffle(seed=42) ensures the same sample can be reproduced each time. The loop then displays three example reviews so we can inspect the data before processing it.
Step 3: Clean and tokenize the text
Next, use spaCy to tokenize each review and remove stopwords, punctuation, whitespace, and non-alphabetic tokens. Lemmatization converts words to their base forms.
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Load spaCy's English processing pipeline</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>nlp = spacy.load("en_core_web_sm")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>def clean_text(text):</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> """Tokenize, remove noise, and lemmatize a text string."""</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> # Process the text with spaCy</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> doc = nlp(text)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> # Keep meaningful alphabetic tokens and convert them to base forms</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> tokens = [</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> token.lemma_.lower()</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> for token in doc</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> if not token.is_stop # Remove common stopwords</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> and not token.is_punct # Remove punctuation</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> and not token.is_space # Remove whitespace tokens</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> and token.is_alpha # Keep alphabetic tokens only</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> ]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> return tokens</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Select the first review from the same dataset sample</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>example = sample[0]["text"]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Apply preprocessing</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>cleaned = clean_text(example)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Compare the original and cleaned versions</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print("BEFORE (raw text):")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(example)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print("\nAFTER (clean tokens):")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(cleaned)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> f"Token count: {len(example.split())} → {len(cleaned)}"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>
spaCy first tokenizes the text into individual units. The filtering rules remove less informative tokens, while lemmatization reduces words to their base forms, producing a cleaner representation for traditional NLP workflows.
Note: The pretrained Transformer used in the next step receives the original review text rather than these cleaned tokens. Modern Transformer models perform their own tokenization and generally work best with text in the form expected during training.
Step 4: Run sentiment analysis with a pretrained transformer
Now load a pretrained DistilBERT sentiment model using Hugging Face’s pipeline() API and run it on the same 20 reviews loaded earlier.
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Load a DistilBERT model trained for sentiment classification</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>classifier = pipeline(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> "sentiment-analysis",</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> model="distilbert-base-uncased-finetuned-sst-2-english"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Extract the original review text from the sample</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>texts = list(sample["text"])</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Run sentiment inference on all 20 reviews</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>predictions = classifier(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> texts,</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> truncation=True</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Display predictions for the first five reviews</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print("Model Predictions (first 5):")</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print("-" * 70)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>for i in range(5):</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> # Model prediction and confidence score</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> pred = predictions[i]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> # Convert the dataset's numeric label to text</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> true = (</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> "POSITIVE"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> if sample[i]["label"] == 1</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> else "NEGATIVE"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> )</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> # Check whether the prediction matches the true label</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> match = "✅" if pred["label"] == true else "❌"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> print(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> f"{match} Predicted: {pred['label']:>8} "</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> f"({pred['score']:.1%}) | Actual: {true:>8}"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> )</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> # Show part of the corresponding review</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> print(f'"{texts[i][:65]}..."')</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> print()</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>
The Hugging Face pipeline handles the model-specific tokenization and Transformer inference internally. For each review, it returns a predicted sentiment label and a confidence score, which we compare with the dataset’s actual label.
Step 5: Evaluate the predictions
Finally, compare the predicted labels with the true Rotten Tomatoes labels using accuracy, precision, recall, and F1-score.
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Convert numeric dataset labels to the same format as model predictions</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>true_labels = [</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> "POSITIVE" if label == 1 else "NEGATIVE"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> for label in sample["label"]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Extract only the predicted labels returned by the model</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>pred_labels = [</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> prediction["label"]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> for prediction in predictions</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Calculate overall classification accuracy</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>accuracy = accuracy_score(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> true_labels,</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> pred_labels</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Count the number of correct predictions</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>correct = sum(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> true == predicted</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> for true, predicted in zip(true_labels, pred_labels)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Print overall accuracy</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> f"Accuracy: {accuracy:.0%} "</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> f"({correct}/{len(true_labels)} correct)"</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print()</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p># Display precision, recall, and F1-score for each class</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>print(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> classification_report(</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> true_labels,</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> pred_labels</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p> )</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>)</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>
accuracy_score() measures the percentage of correctly classified reviews. classification_report() provides a more detailed view using precision, recall, and F1-score for both positive and negative sentiment classes.
Wrapping up
NLP applications vary by industry, but they share the same goal, which is turning human language into information or actions that support a specific task. Customer support systems classify and route requests, healthcare systems extract clinical entities, and sentiment models identify opinions across large volumes of text.
If you are ready to explore natural-language interfaces for enterprise data, read our white paper: Measuring the Value of Natural Language Query Implementation Over a Semantic Layer.
Frequently asked questions
What are common applications of natural language processing?
Common NLP applications include chatbots, service desk automation, voice assistants, natural-language business intelligence, sentiment analysis, healthcare information extraction, biomedical research, and SEO analysis.
How is NLP used in customer support?
NLP can classify customer requests, identify intent and entities, retrieve relevant information, summarize conversations, and route issues to the appropriate workflow or support team.
Is sentiment analysis an application of NLP?
Yes. Sentiment analysis is an NLP application that identifies opinions or emotions in text, often classifying them as positive, negative, or neutral. Modern systems can use embeddings and Transformers to interpret context, negation, intent, and emotion.
Can I do sentiment analysis without natural language processing?
Basic sentiment scoring can use keyword or lexicon matching without advanced NLP models. However, understanding negation, context, sarcasm, entities, and domain-specific language typically requires NLP techniques.
How can you implement an NLP use case in Python?
A typical workflow includes loading language data, preprocessing or tokenizing the input, running a task-specific or pretrained model, and evaluating its output. In this article, the sentiment.