NLP for sentiment analysis

Beyond Text Mining: NLP for Sentiment Analysis

Sentiment analysis (SA), sometimes referred to as opinion mining, is the specialised field of natural language processing (NLP) that systematically identifies, extracts, and understands subjective information and emotional tone embedded within text data.

From guiding product development to enhancing brand reputation and even informing public policy, SA is enabling organisations, researchers, and individuals to navigate the complex tapestry of human expression in the digital age.

The Emergence of Sentiment Analysis, Or, The Why Behind the What

The widespread need for SA first emerged in response to the rapid increase in user-generated content—in the late 1990s and the early 2000s—driven by the growth of social media sites and community forums.

Before sentiment analysis techniques gained prominence, traditional text analysis tools—driven by natural language processing techniques—were adept at extracting factual information: Identifying entities (people, places, organisations), understanding topics, summarising content and so forth. As the volume of online commentary swelled, businesses and institutions quickly encountered a critical limitation: Knowing what was being discussed was no longer sufficient. They needed to know how people felt about it.

Consider the deluge of customer reviews on e-commerce sites, the vibrant discussions in online communities, or the sheer volume of tweets about a new product or political development. A traditional NLP system could efficiently tell a company that its product was mentioned, and what features were being talked about. But it couldn’t tell them whether customers liked those features, whether they were frustrated with the user experience, or whether their sentiments towards the brand were positive, negative, or indifferent.

Companies began to understand that for customer loyalty, brand reputation, and future product development, they needed more than assessments of the soundness of features and functionalities. They needed to gauge the emotional resonance of their offerings. They needed insights into human perception and experience.

This demand for qualitative understanding at scale—analyses of the attitudes and emotions contained in subjective statements—was the primary catalyst for the development and widespread adoption of sentiment analysis tools.

How Sentiment Analysis Tools Go Beyond The Literal

Sentiment analysis tools take text mining into a domain beyond the capabilities of general natural language processing models. Think of SA as one component—which performs a specific, deep layer of interpretive analysis—within the broader field of NLP. We’ll illustrate this with examples of analyses of customer reviews on Amazon.

Nuanced Meaning in Product Reviews

Imagine a customer review that states: “These headphones are so lightweight, you won’t even realise you’re wearing them!

A general NLP model would accurately parse this sentence to understand that the headphones possess the attribute of being low in terms of weight, and that the user’s perception involved wearing them. It would identify the keywords “lightweight” and “wearing” and then quantify “low weight” as a characteristic; if it had rules for intensifiers, it would understand that the word “very” increases the importance of the word “lightweight.” However, its interpretation would remain at a literal, factual level—and it would not infer the subjective value of the “lightweight” attribute.

SA delves into the implication of the statement. It would understand that “lightweight” in the context of headphones is not just a physical property but a highly desirable attribute associated with superior user comfort—at least in the case of the user who wrote the sentence. (The phrase “you won’t even realise you’re wearing them” would be interpreted as a strong positive indicator of comfort.) A sentiment analysis model would conclude that the statement indicates a strong positive sentiment towards the headphones’ comfort level, and it would assign a high positive score for the comfort aspect.

The capability to infer a subjective benefit from a factual characteristic is what distinguishes SA here. For this, the sentiment analysis model draws upon its training on vast datasets where such positive or negative associations (“lightweight” equating to “comfortable” for wearable tech) are commonly observed (and tagged with positive sentiment).

Implicit Negative Sentiment and Rhetorical Frustration

Now imagine a review that reads: “I have only one question: Why does Amazon even stock this keyboard?

For NLP that uses no sentiment analysis techniques, this would be a literal question about inventory or procurement. The model would correctly identify the keywords as “stock” and “keyboard”—and incorrectly identify the structure of the review as interrogative. Without a dedicated SA layer, it would fail to detect the underlying emotional charge.

A well-trained sentiment analysis model would recognise the deeply negative sentiment of exasperation in the rhetorical question. It would understand that the user was not seeking a logistical explanation for Amazon’s inventory choices, but expressing profound dissatisfaction with the keyboard—even outrage. The model would interpret the sentence as a strongly negative review of a keyboard that was perceived as seriously deficient.

Figurative Language: Hyperbole and Overwhelm

Say a concert-goer puts up this social media post after a loud and chaotic show: “My ears are still ringing, the bass was so loud it shook my teeth out, the crowd was so packed you couldn’t move. Honestly, I’m never going to another concert again!

An NLP-based text analysis tool would identify the keyphrases “ringing,” “loud,” “shook my teeth out,” and “packed”—potentially flagging these as descriptive terms. While it would note that the statement “never going to another concert again” was explicitly negative, its analysis might focus on the factual elements of the volume and crowd density at the concert.

Sentiment analysis tools would understand the overwhelmingly negative emotional experience being conveyed. “Shook my teeth out” is a non-literal, hyperbolic phrase—but an SA tool would recognise it as an expression of discomfort. The phrase “couldn’t move” would contribute to a negative sentiment score for crowd comfort. It’s important to note that even though each phrase in the first sentence is neutral, the SA tool would (a) aggregate the intense descriptors; (b) combine them with the explicit statement of future avoidance; and (c) infer a strong overall negative sentiment as well as overwhelm. In fact, this example illustrates the ability of sentiment analysis tools to synthesise textual elements—including those that use figurative language—into a holistic expression of emotion.

The above examples demonstrate how SA “overlaid” on general NLP enables connotation, in addition to denotation, to be extracted—which is required if raw textual data is to be correctly and fully understood.

How Sentiment Analysis Works: Approaches, Limitations, Challenges

At the basic level, all sentiment analysis tools equip AI with the ability to interpret emotional and subjective content embedded within language. They systematically analyse textual content, in a context-aware manner, to classify encountered sentiments as positive, negative, or neutral. More advanced SA tools recognise distinct emotions such as joy, anger, fear, and surprise. Typically, sentiment analysis models first look for emotionally loaded words and phrases (“wonderful”, “dreadful”, “disappointing”), which are explicit sentiment indicators. They consider linguistic modifiers such as intensifiers (“extremely,” “very,” “barely”) and negations (“not,” “never”), which substantially impact the interpretation of emotion. Competent processing of elements such as sarcasm or irony requires deeper contextual understanding.

Beyond those basics, let’s look at four broad approaches to sentiment analysis:

Lexicon-based sentiment analysis: This foundational method uses sentiment lexicons—extensive word lists pre-populated with terms and phrases, each assigned a predefined sentiment score (say +1 for positive, -1 for negative, 0 for neutral) or an emotional label. When analysing text, the SA model scans for matches against the lexicon, sums the scores of the identified words, and aggregates them to determine the overall sentiment of a sentence, paragraph, or document.

The relative ease of implementation makes this a good starting point for general sentiment detection. But lexicon-based systems are limited in terms of adaptability; they struggle when faced with ambiguous expressions, or expressions that just don’t exist in their lexicons.

Aspect-Based Sentiment Analysis (ABSA): This represents a more advanced and granular sentiment analysis technique. Beyond identifying the overall sentiment of a document or even a sentence, ABSA aims to pinpoint what sentiments are expressed towards which aspects, features, or topics.

For instance, in a review that says “The camera on this phone is absolutely brilliant, but the battery life is utterly dreadful—plus it overheats quickly,” a general sentiment analysis tool might register a mixed or slightly negative sentiment. ABSA, however, would identify strongly positive sentiment towards “camera,” strongly negative sentiment towards “battery life,” and negative sentiment towards “overheating.” For this, the tool needs to understand named entities (“camera,” “battery”) and the relationship between those entities and descriptive words (“brilliant,” “dreadful”) so it can assign the correct sentiment to each aspect.

This level of detail is invaluable for targeted insights, such as in product development. Accurately associating sentiments with particular entities, though, remains a complex and actively evolving area of NLP research.

Machine Learning (ML) models: ML models must be used if more nuanced, context-aware, and scalable sentiment detection is the goal. Unlike lexicon-based systems, ML models are trained on vast sentiment analysis datasets that have been meticulously labelled, by human annotators, with their corresponding sentiment.

Through their training, ML models learn complex patterns, linguistic relationships, and subtle contextual cues that indicate certain sentiments. They learn not only the sentiments associated with individual words but also how those sentiments shift with context.

This allows them to generalise—so they can go beyond keyword matching to infer sentiment from previously unseen text, and they can adapt to new vocabulary. Thus, an ML model trained on product reviews might learn that “flimsy” consistently indicates a negative sentiment about build quality. For a lexicon-based SA model to know this, the word “flimsy” would need to be present (and labelled!) in its sentiment lexicon.

Still, even with the ability to generalise from annotated training data, the accuracy of an ML model is directly dependent on the quality of that data.

Large Language Model (LLM)-Driven sentiment analysis: This represents a significant leap in the use of natural language processing techniques for sentiment analysis. It leverages the inherent language-understanding capabilities of Large Language Models (LLMs) like GPT and BERT. Unlike the other approaches we’ve mentioned—which either rely on pre-defined lexicons or require extensive, labelled training to learn language patterns from scratch—LLMs are “pre-equipped” with fabulous proficiency in understanding and generating human language. They have been trained on unimaginably vast amounts of text, which enables them to grasp context, nuance, sarcasm, and irony—and discern sentiment with impressive accuracy—without the need for sentiment-labelled datasets.

The emergence of LLMs—particularly the widespread availability of powerful models around 2018-2020—has dramatically shifted the landscape of what’s possible in sentiment analysis. Models including BERT and GPT-3 gained prominence around that time; LLMs surged in public awareness with tools such as ChatGPT late 2022 on.

But LLMs present their own set of considerations—considerations that often lead organisations to still consider traditional approaches:

  • They demand significant computational resources for deployment and operation, which leads to higher costs.
  • The sheer complexity of LLMs can make it difficult to understand why they arrived at a particular sentiment classification. This can be a drawback for use cases that require high interpretability or auditability.
  • The output of an LLM might reflect biases in its vast training data.
  • LLMs occasionally produce “hallucinations”—less predictable, “off-the-mark” outputs—unlike with, say, purpose-built ML models.

The choice of approach, therefore, depends on budget and the scale of the endeavour. It is also a trade-off between the desirability of linguistic sophistication and the need for “explainability,” which refers to the ability to explain why a model produced a certain output.

Key Challenges and Limitations

Despite ongoing progress, linguistic complexities pose substantial hurdles to effective SA. Understanding the challenges is crucial to setting realistic expectations about what SA can achieve.

Negation handling and intensifiers: One challenge that stands out because it appears deceptively simple is the interpretation of negations (“not terrible,” “not good”) and intensifiers (“very,” “extremely,” “hardly,” and “barely”). At face value, negations such as “not” simply flip meaning—and, therefore, sentiment. In practice, their usage in human language is so nuanced and varied that it poses a challenge to AI systems.

Modern sentiment analysis models typically handle negations through extensive training on diverse, annotated textual datasets, which is why they can recognise common linguistic patterns. For instance, SA models have learnt that “not bad” typically conveys mild positivity whereas “not good” expresses clear negativity. Similarly, they have learnt that subtle intensifiers introduce complexity—for instance, “hardly” can act as a negator: “Hardly good” expresses clear negativity, and “hardly a problem” conveys reassurance or positivity. Good SA models rely on contextual cues and training examples to effectively handle subtleties of this nature.

Less common or idiomatic structures remain problematic, especially where the training data is insufficient. Consider the statement “I wouldn’t say it was great” versus “I couldn’t say it was bad.” Both statements use negation on a clearly positive or clearly negative word, but the implied sentiments differ markedly: The first suggests mild negativity or neutrality—and the second, mild positivity but not neutrality. Accurately interpreting such expressions, which are ambiguous at a textual level, continues to challenge even sophisticated SA models.

Understanding sarcasm and irony: These human-language constructs present formidable challenges for sentiment analysis models. They convey sentiments contrary to the literal meanings of the words used: For instance, the exclamatory “Oh, fantastic, another rainy weekend!” expresses frustration even though it is positive at the textual level. A lexicon-based system would parse “fantastic” independently of its context—and infer positive emotion.

Reliable emotion detection in such cases demands knowledge of common idioms, contextual understanding, awareness of conversational cues, and sensitivity to incongruities between literal meaning and implied sentiment. While modern SA models increasingly consider contextual patterns—such as exclamations combined with negative subject matter, or unexpected word pairings—to improve emotion detection, it remains an exceptionally difficult task.

Contextual ambiguity: Contextual ambiguity further complicates SA accuracy: The same word or expression can dramatically shift sentiment based on its immediate context or colloquial usage. Consider the adjectival “killer”: In its most common and literal sense, it denotes something or someone that causes death (“a killer virus”)—which, of course, connotes a strong negative sentiment. But in informal usage—as in “the killer ingredient in this recipe” or “a killer performance”—the word conveys enthusiastic approval.

Implicitly conveyed sentiment: Sentiment may even be conveyed implicitly. A customer review that lists multiple minor issues without using explicitly negative language—for instance, “Small rooms, narrow corridors, slow service”—implicitly communicates dissatisfaction. Similarly, in a review that only lists features along with mild negative modifiers, the sheer number of features and negatives implicitly conveys a negative sentiment. SA must detect these subtle implications through contextual cues.

Slang, emoticons, and rapid language evolution: Social media introduces another layer of complexity through constantly evolving slang, emoticons, abbreviations, and internet-specific terminology. New expressions keep appearing and quickly become emotionally significant within specific communities. SA systems must continuously adapt to be able to accurately interpret rapidly evolving language patterns accurately. This requires substantial resources, ongoing data updates, and sustained research effort.

Domain-specific terminology: Terms may carry differing sentiments or factual implications depending on the context or field of activity. For instance, “aggressive” indicates undesirable behaviour in a general social context; the sentence “His aggressive conduct led to his dismissal” conveys a negative overall sentiment. However, in the business or marketing domains, describing a company as having “an aggressive strategy” typically conveys the positive sentiments of boldness, determination, and competitive drive. To effectively handle these subtleties, a sentiment analysis model must be trained specifically for each domain; it will otherwise require custom adaptation, which would complicate its deployment across sectors.

Ethno-cultural variations: Regional dialects and variations in communication styles pose a challenge to SA models across all major global languages. For variations of a language spoken in different regions, especially in informal online settings, norms of expression—for formality and politeness, as one example—can vary significantly.

To illustrate, consider indirectness in variants of English. In cultures that value direct communication, “The proposed solution is not without its difficulties” would be considered mildly negative; in communication styles where politeness through indirectness is valued, the phrase would be a strongly negative pronouncement of impracticality. Most commercial SA systems are trained on readily available, “universal” corpora that are de facto US-centric in their linguistic bias—which leaves them incapable of picking up on such regional variations.

Addressing this issue would require training SA models on geographically and culturally specific annotated corpora; such bespoke adaptation is often prohibitively expensive and time-consuming.

Dependence on quality and availability of training data: The accuracy, generalisation ability, and reliability of SA models are fundamentally dependent on the quality, representativeness, and comprehensiveness of annotated training data. Developing large, accurately labelled sentiment analysis datasets—particularly for niche domains, specific industries, or less-common languages—is challenging and expensive.

In sum, SA represents a powerful advancement within the field of NLP—but it still operates within certain boundaries. The inherent complexities, ambiguities, and continuous evolution of human language mean that performance depends heavily on contextually informed training and continual refinement. This underscores the importance of ongoing research, careful training-data selection, and realistic expectations regarding current capabilities and future potential.

Implementation, too, demands a clear awareness of the limitations of SA models. For high-stakes applications, human supervision might be required so that the output of the model may be validated.

Key Applications of Sentiment Analysis

Sentiment analysis tools drive decisions across a range of industries and scenarios. The applications of SA span well-established, mature uses to innovative, futuristic implementations that are pushing the boundaries of what’s possible.

Market research and strategy: SA offers a dynamic and immediate lens into the broader market landscape. Market research firms and strategists use sentiment analysis tools to track public sentiment not just about their own offerings, but also about industry trends, emerging technologies, and, critically, their competitors. By analysing news articles, industry blogs, and competitive reviews, they can identify market gaps, assess the strengths and weaknesses of rivals from the standpoint of public perception, and better position their own products or services.

Human Resources: SA can provide profound insights into internal organisational health. HR departments can apply SA to anonymised employee surveys, internal communication platforms, and feedback tools. This helps uncover patterns of sentiment related to company culture, management styles, policies (remote work, benefits), or recent organisational changes. Such analysis can reveal progressing dissatisfaction, or areas of high morale, that might otherwise be missed—which enables HR departments to proactively address concerns, foster more positive work environments, and improve employee retention.

For entertainment and content platforms: From streaming video services to music apps and news aggregators, companies are exploring the advanced personalisation made possible by SA. Analyses of the tone of user comments and reviews—and even the sentiment implicit in viewing habits (“does the user more frequently watch comedies or dramas?”)—enable companies to dynamically adjust content recommendations to suggest media that not only aligns with users’ past preferences but also uplifts their current mood.

Brand monitoring and improved CX: Analysing customer reviews and social media comments is arguably one of the most mature and widely adopted applications of SA. From e-commerce giants to hospitality chains, businesses constantly monitor customer reviews on their products, services, and overall brand. Beyond direct reviews, they leverage SA to trawl through public mentions, comments, and discussions on social media platforms. This enables them to pinpoint prevailing public sentiments, track shifts in brand perception in near real-time, and identify specific pain points or moments of delight. Crucially, it allows for proactive engagement: Swiftly addressing negative feedback to mitigate reputational damage or amplifying positive testimonials to strengthen brand image.

Customer service and sales: SA provides live sentiment feedback during sales calls and post-call insights to refine scripts, which is revolutionising agent training and interaction quality. During a live call, advanced SA systems can provide real-time prompts to agents, indicating the caller’s sentiment (“prospect sounds sceptical,” “customer seems frustrated”). Post-call, running sentiment analysis algorithms on call transcripts and audio recordings results in identification of elements such as customer objections, moments of high engagement, and phrases that resonated with the customer. This data is then used to refine sales scripts, improve objection handling, and provide targeted coaching to agents—all of which ultimately boost conversion rates and customer satisfaction.

Such analysis and training capabilities move beyond sentiment analysis on text. They include analysis of “vocalics”—the non-verbal elements of a speaker’s voice such as pitch, rate of speech, volume and so forth—that convey emotion.

Online learning: Spotting frustration or confusion in student forum posts and open-ended answers helps instructors provide timely support. SA can play a crucial role in enhancing pedagogical effectiveness: By analysing student interactions in discussion forums, their responses to open-ended questions, or even their written assignments, SA can identify patterns of frustration, confusion, or disengagement. This provides educators with timely alerts that allow them to proactively reach out to struggling students, offer additional support, or clarify challenging concepts before academic difficulties become entrenched.

Product development: For product managers and development teams, SA helps by identifying feature likes and dislikes from feedback. By applying Aspect-Based Sentiment Analysis (ABSA) to user reviews, survey responses, and forum discussions, development teams can precisely identify which specific features of a product (such as a phone’s camera, a software’s user interface, a car’s fuel efficiency) are liked or disliked. This granular feedback directly informs iterative product improvements, highlights areas that require redesign, and guides the prioritisation of new feature development.

Creative communications: Marketers, public relations specialists, and other creative professionals use sentiment analysis tools as writing assistants to analyse draft articles, press releases, and marketing copy before publication to ensure the intended emotional tone is conveyed. SA tools identify passages where negative sentiment is unintentionally introduced, where the voice seems inconsistent, or where the message might be misconstrued—and provide sentiment-aligned suggestions for rewrites.

The financial sector: The financial sector has been an early and aggressive adopter of SA. Investment firms use market sentiment analysis algorithms to understand the tone and mood conveyed in publicly available texts (analyst reports, news articles, high-volume financial forums). This understanding helps generate “mood indices” that capture the emotional pulse of the market as a whole, or of specific companies, which in turn helps identify shifts in market sentiment that precede price movements in stocks and commodities. In essence, market sentiment analysis provides supplementary indicators that investment firms and automated trading systems often factor into decisions and strategies.

Supply chain management: In the intricate world of SCM, SA adds a layer of qualitative intelligence. Beyond traditional metrics, sentiment analysis algorithms can continuously scan global news feeds, industry reports, and internal supplier communications. Whether it is related to labour disputes, political instability in a manufacturing region, adverse weather forecasts that use uncharacteristic language, or public discontent regarding a supplier’s ethical practices, early detection of negative sentiment acts as an early warning. It allows companies to mitigate potential disruptions before they significantly impact logistics, production schedules, or supply availability.

Brand safety in ad placements: For companies that run online advertising campaigns, maintaining brand safety and safeguarding reputation is paramount. SA-enabled ad-serving platforms continuously scan web pages—including user-generated content (comments sections, forums)—to flag content that contains extreme negative sentiment, hate speech, or highly sarcastic language. The system can dynamically remove ads from the relevant page in near-real time—or prevent future placements there.

Smart city planning: This innovative application sees urban planners and city councils leveraging SA to gauge the “mood” of urban areas. By aggregating and analysing sentiment expressed in geotagged social media posts, local online forums, and community feedback platforms, they can create “sentiment heatmaps” of multiple neighbourhoods. These maps can highlight areas with significant dissatisfaction related to public transport, crime, cleanliness, or the lack of green spaces. Conversely, they can pinpoint areas of high satisfaction with local amenities or community initiatives. Such feedback informs targeted urban development projects, resource allocation, and overall city design aimed at improving residents’ quality of life.

More effective telemedicine: An emerging, promising application of SA combines text and voice analysis to build a richer emotional profile for telemedicine practitioners. During video consultations, sentiment analysis algorithms can analyse a patient’s language in text chats and written symptoms. Importantly, they can interpret emotional cues from their tone (pitch, volume, speech rate) during spoken interactions. This helps doctors gain an understanding of a patient’s emotional well-being that goes beyond their documented physical symptoms, which is particularly useful in identifying underlying anxiety or other forms of distress that might be less apparent in a purely remote setting. The result is more empathetic, more comprehensive patient care.

Detecting and addressing public concerns in times of crisis: Governments, emergency services, and public relations teams can—in periods of crises and natural disasters—continuously monitor large volumes of comments across social media and news feeds. Social media sentiment analysis helps detect emerging public concerns, track the spread of rumours, and gauge the collective emotional response of the people concerned. This real-time situational awareness enables authorities to tailor their communications more effectively, deploy resources proactively, and address critical public sentiment before it escalates.

In Conclusion

Sentiment analysis demonstrates the transformative power of natural language processing solutions in extracting insights from the seemingly chaotic world of human communication. From its fundamental ability to categorise emotions to its advanced capacity for nuanced, context-specific understanding, SA offers a lens into individual emotional states and collective public opinion.

Challenges abound: Accurate identification of emotion in nuanced language, the navigation of contextual ambiguities, and ever-evolving online slang. Continual advancements in data availability and ML models promise ever-increasing accuracy and broader utility.

As our digital interactions continue to generate overwhelming volumes of text data, SA will increasingly be seen as a strategic, indispensable tool for businesses, governments, researchers, and communicators.

References and Further Reading

Sentiment Analysis: A Q&A Summary

In one sentence, what is sentiment analysis? +
What is the purpose of SA? +
Is SA a new development? +
How does SA go beyond traditional natural language processing techniques? +
What are the main approaches used in sentiment analysis models? +
What is the simplest, most basic approach to SA? +
What does “Aspect-Based Sentiment Analysis” refer to? +
Why are Machine Learning (ML) models used in sentiment detection? +
What is the role of Large Language Models (LLMs) in sentiment analysis? +
What are the challenges in deploying LLMs for SA? +
What are some key linguistic complexities that challenge sentiment analysis models? +
What are some common and widespread applications of sentiment analysis? +
How is SA used in customer service and sales? +
What are some interesting or emerging uses for SA? +
Scroll to Top