Text Attitude Analysis: A Practical NLP Guide from Sentiment to Cognition

A practical guide to building multi-layered attitude analysis pipelines using NLP tools and social psychology theory.
This article presents a comprehensive framework for text attitude analysis grounded in the ABC Model of Attitudes from social psychology. It decomposes the task into three layers—valence (VADER, RoBERTa), affect (NRC Lexicon, DistilRoBERTa), and cognition (stance detection, ABSA, LLM zero-shot extraction)—and recommends practical Python/R tool combinations for building an integrated attitude analysis pipeline.
Introduction: Attitude Analysis Goes Beyond Sentiment Analysis
In the field of Natural Language Processing (NLP), Sentiment Analysis has long been a mature application area. Since the early 2000s, sentiment analysis has developed into one of the most commercialized applications in NLP, widely used for product review mining, brand monitoring, and public opinion analysis. Its core assumption is that text can be mapped onto a continuous spectrum from positive to negative. However, systematically analyzing a person's "attitude" from text data is a far more challenging requirement. This involves not just simple positive/negative polarity judgment, but also distinguishing between multiple psychological dimensions of attitude.
Social psychology research shows that human attitudes are multidimensional psychological constructs that cannot be simply reduced to a single polarity value. Attitudes encompass not only emotional reactions but also cognitive judgments and behavioral tendencies. Attitude analysis touches the intersection of computational social science and psycholinguistics, making it more complex than traditional sentiment analysis because it attempts to reconstruct the complete cognitive process within human psychological structures. Computational Social Science emerged precisely in this context, seeking to quantify complex concepts from traditional social sciences using computational methods, and attitude analysis is one of its most representative research directions. This article will outline the theoretical framework for attitude analysis and recommend a practical set of R/Python tools that can be implemented in production.
The ABC Model of Attitudes: Theoretical Foundation
The theoretical basis of attitude analysis is the classic ABC Model of Attitudes from social psychology, which holds that attitudes consist of three components. This model can be traced back to the tripartite theory of attitudes proposed by Rosenberg and Hovland in 1960, later systematically elaborated by Eagly and Chaiken (1993) in their book The Psychology of Attitudes. The model posits that attitude is a lasting evaluative tendency toward a specific object, composed of three components: Cognitive, Affective, and Behavioral/Conative. It's worth noting that in different literature, the third component is sometimes expressed as "behavioral tendency." In this article, Valence is treated as an integrative evaluative dimension—a simplified approach oriented toward NLP implementation. This model is widely applied in consumer behavior research, political attitude studies, and health psychology.
Cognitive Component
The cognitive component refers to people's beliefs, thoughts, and ideas about the attitude object. For example, the statement "snakes are dangerous" reflects the subject's factual judgment or cognitive evaluation of the object. At the NLP level, this requires identifying assertions and belief expressions in text. Linguistically, the cognitive component often manifests as propositional content—statements that can be judged as true or false—which makes it syntactically and semantically distinct from emotional expressions.
Affective Component
The affective component refers to the subject's emotional or affective reactions to the attitude object, such as "I'm afraid of snakes." This dimension is where traditional sentiment analysis excels, but attitude analysis demands more fine-grained emotion classification (fear, anger, joy, etc.) rather than just positive/negative polarity. Emotion psychology research shows that different discrete emotions drive different behavioral responses—fear leads to avoidance, anger leads to confrontation, disgust leads to rejection—making the distinction between specific emotion types valuable for predicting behavioral tendencies.
Valence Component
Valence assigns an overall positive, negative, or neutral polarity label to the attitude. This is the component closest to classic sentiment analysis among the three, and also the easiest to implement with off-the-shelf tools. Valence can be understood as the combined result of cognitive evaluation and emotional reaction, providing a summary directional indicator for the attitude.
Understanding this theoretical framework is crucial because it dictates that the technical solution must be decomposed into layers rather than relying on a single model for an all-in-one solution.
Valence Analysis Tools: A Mature NLP Ecosystem
For valence (positive/negative/neutral) judgment, both R and Python ecosystems offer numerous mature solutions.
Python Valence Analysis Tools
- VADER (Valence Aware Dictionary and sEntiment Reasoner): A rule + lexicon method designed specifically for social media text that directly outputs composite valence scores. VADER was published by C.J. Hutto and Eric Gilbert at the ICWSM conference in 2014, with its design philosophy combining lexicon methods and simple rules to handle the unique features of social media text. Unlike pure machine learning approaches, VADER incorporates a manually annotated and validated sentiment lexicon (approximately 7,500 entries) and processes text through five heuristic rules handling punctuation (e.g., the intensifying effect of exclamation marks), capitalization, degree adverbs, the contrastive semantics of the conjunction "but," and negation words. Its compound score output ranges from -1 to +1, providing intuitive polarity judgment. VADER's advantages include requiring no training data, fast execution speed, and good coverage of informal text (including emojis and internet slang), while its disadvantages are lack of contextual understanding and cross-domain transfer capability.
- TextBlob: Provides simple polarity and subjectivity scores, suitable for rapid prototyping
- Transformer models: Such as
cardiffnlp/twitter-roberta-base-sentimenton Hugging Face, offering higher accuracy. This model is based on the RoBERTa architecture, pre-trained on approximately 58 million tweets for language modeling, then fine-tuned on the TweetEval sentiment analysis benchmark, capable of capturing implicit semantics and contextual information in social media text.
R Valence Analysis Tools
- sentimentr package: Handles contextual factors such as negation words and degree adverbs, with its core algorithm based on a shifting window method to detect the scope of polarity modifiers
- syuzhet package: Provides interfaces to multiple sentiment lexicons (including the NRC lexicon)
The technology at the valence level is quite stable and is typically not the bottleneck in attitude analysis.
Affective Component Analysis: Fine-Grained Emotion Recognition Methods
To capture specific emotions like "fear," "disgust," and "love," we need multi-label emotion classification that goes beyond binary polarity.
Lexicon-Based Emotion Recognition
The NRC Emotion Lexicon (NRC Emotion Lexicon) is a classic resource in this field, covering Plutchik's eight basic emotions. Robert Plutchik's Wheel of Emotions model, proposed in 1980, organizes human emotions into opposing pairs of eight basic emotions: joy-sadness, trust-disgust, fear-anger, surprise-anticipation. The NRC Emotion Lexicon (also known as EmoLex) was developed by Saif Mohammad at the National Research Council of Canada in 2013, using crowdsourced annotation (Amazon Mechanical Turk) to label over 14,000 English words with Plutchik's eight emotions plus positive/negative polarity. The lexicon has been translated into over 100 languages, making it an important resource for cross-lingual emotion analysis. Its limitation is that lexicon-based methods cannot handle sarcasm, metaphor, and context-dependent emotional expressions. It can be accessed directly through R's syuzhet package and Python's NRCLex library.
Deep Learning-Based Emotion Classification
A more modern approach uses fine-tuned deep learning models. For example, j-hartmann/emotion-english-distilroberta-base on Hugging Face can classify text into categories such as anger, disgust, fear, joy, neutral, sadness, and surprise. This model is based on the DistilRoBERTa architecture (a distilled version of RoBERTa with 40% fewer parameters while retaining 97% performance), fine-tuned on multiple emotion-annotated datasets. For a sentence like "I'm afraid of snakes," such models can accurately identify the "fear" label, corresponding precisely to the affective component of attitude.
Cognitive Component Analysis: The Most Challenging NLP Dimension
Identifying the cognitive component is the most difficult part of the entire attitude analysis task, because extracting "beliefs" and "thoughts" involves deeper semantic understanding. Currently, no single off-the-shelf model can directly accomplish this task, but several viable paths exist:
Approach 1: Stance Detection
Stance detection aims to determine whether a text author holds a supportive, opposing, or neutral stance toward a specific target. Conceptually, this closely approximates modeling the cognitive component. Stance detection emerged as an independent NLP task from the 2016 SemEval shared task (Task 6: Detecting Stance in Tweets), requiring models to determine tweet authors' stances toward five predefined targets (e.g., "Climate Change is a Real Concern," "Feminist Movement"). The key distinction from sentiment analysis is: sentiment analysis judges the emotional tone of the text itself, while stance detection judges the author's cognitive attitude toward a specific target—a negatively-toned text might actually express support for a target (e.g., by criticizing opponents to indirectly express support). In recent years, zero-shot stance detection has become a research hotspot, aiming to enable models to make stance judgments on targets unseen during training. SemEval stance detection task datasets and models are available for reference, and Hugging Face hosts several pre-trained stance detection models.
Approach 2: Aspect-Based Sentiment Analysis (ABSA)
Aspect-Based Sentiment Analysis can identify evaluations directed at specific objects (aspects) in text. ABSA was formally defined as an NLP benchmark task in SemEval 2014 Task 4, encompassing four subtasks: aspect category detection, aspect term extraction, aspect category polarity classification, and aspect term polarity classification. By setting "snake" as the aspect, cognitive descriptions such as "dangerous" can be extracted for that object. In attitude analysis scenarios, ABSA's value lies in its ability to separate different evaluations of different objects within text—for example, in "this phone has a great camera but disappointing battery life," the camera and battery life receive different polarity judgments respectively. PyABSA is a fully-featured open-source library developed by Yang Haipeng et al., integrating multiple pre-trained models (such as LCF-BERT, FAST-LSA) for aspect-level sentiment classification.
Approach 3: Zero-Shot Extraction with Large Language Models
For tasks like cognitive belief extraction that are difficult to cover with traditional supervised learning, directly calling large language models such as GPT-4 or Claude for structured extraction may be the most practical approach. Using LLMs for zero-shot structured extraction is a rapidly developing technical path since 2023, with its core idea being to guide models through carefully designed prompts (prompt engineering) to convert unstructured text into structured JSON or tabular output. Through carefully designed prompts that request the model to output "belief-emotion-valence" triplets in JSON format, this approach often achieves results superior to traditional pipelines. The advantages of this method are extremely high flexibility and no need for labeled data, while disadvantages include higher cost, partially uncontrollable output, and reproducibility challenges. Researchers can improve output stability by setting temperature to 0 and using structured output constraints (such as OpenAI's function calling or JSON mode).
Recommended Integrated Attitude Analysis Pipeline
Based on the above analysis, a pragmatic attitude analysis pipeline can be assembled as follows:
| Analysis Layer | Recommended Tools | Output |
|---|---|---|
| Valence Layer | VADER or RoBERTa sentiment model | Positive/Negative/Neutral scores |
| Affective Layer | DistilRoBERTa emotion model or NRC Lexicon | Fine-grained emotion labels |
| Cognitive Layer | LLM zero-shot extraction / Stance detection / ABSA | Belief statements and cognitive evaluations |
After each of these three layers produces results, they are aggregated by attitude object. The entire workflow can be implemented in Python using the Hugging Face transformers library and OpenAI/Anthropic APIs; in R, Python models can be bridged via the reticulate package, or the text package (an R-native NLP tool based on Transformers) can be used.
The R text package was developed by Oscar Kjell et al. and formally published in Behavior Research Methods in 2023, aiming to provide R users with native NLP capabilities based on Transformer models without switching to a Python environment. The package supports text embedding generation, semantic similarity computation, and downstream tasks based on BERT-family models. The reticulate package, maintained by the RStudio team, is a Python-R interoperability solution that allows direct calling of Python functions and objects within an R session, enabling R users to seamlessly use all models in the Hugging Face ecosystem. Each approach has its trade-offs: the text package provides a purer R experience but with limited model coverage, while reticulate provides complete Python ecosystem access but adds environment configuration complexity.
Conclusion: Attitude Analysis in an Interdisciplinary Perspective
Attitude analysis is a quintessential interdisciplinary topic that requires researchers to both understand the theoretical frameworks of social psychology and master modern NLP toolchains. Rather than searching for a "universal model," it's better to decompose the problem into three independently processable subtasks—valence, affect, and cognition—based on the ABC model, and then integrate the results.
As large language model capabilities continue to improve, these complex psycho-semantic extraction tasks will become increasingly feasible—but understanding the underlying theoretical framework remains the prerequisite for building reliable attitude analysis systems. In practical applications, researchers also need to address validity verification of attitude analysis results: evaluating system reliability through comparison with manual annotations (inter-annotator agreement), correlation analysis with scale measurement results, and performance on downstream prediction tasks.
Key Takeaways
Related articles

The Logic Behind Stripe's $7 Billion Acquisition of OpenRouter: Why Chasing Trends Actually Works
Stripe acquires AI aggregation platform OpenRouter for $7B. Founder Alex's pivot from NFTs to AI reveals the core logic: trends are low-cost training grounds, and reusable capability frameworks are what truly hold value.

Crankwave: A Detailed Look at the Open-Source Engine Sound Simulation and Baking Tool
An in-depth look at Crankwave, an MIT-licensed open-source engine sound simulator and audio baking tool supporting JSON config, WASM execution, deterministic baking, and simulator-free playback for game developers.

Claude Code vs Codex: A Deep Comparison to Help You Choose the Right AI Coding Assistant
Deep comparison of Claude Code vs Codex: architecture differences, behavior patterns, and use cases. Based on SWE-RPG benchmark data, choose the right AI coding assistant for your team.