DH 2026

Daejeon, July 27–31

Fri, July 3111:00–12:30S060209-211
Short Paper

Based on BERT: A Full-Book Character Analysis System for Modern Chinese Classics—Using Dream of the Red Chamber as an Example

Yihang Peng
Tsinghua University, People's Republic of China · 7726972852@qq.com
Ye Wang
Tsinghua University, People's Republic of China · Alexye.wang22@gmail.com

Background and Motivation

Dream of the Red Chamber(abbreviated as DRC below) is one of the pinnacles of Chinese classical fiction, characterized by intricate interpersonal relationships and abundant metaphorical expressions. Previous scholarship has often relied on manually selecting a subset of metaphorical sentences for character interpretation. However, for DRC and similar modern-era classical texts, efficient tools capable of performing full-book metaphor detection and sentiment analysis remain lacking. Manual processing is time-consuming and difficult to scale, while existing automated methods face limitations:

(1)BERT-based models, although strong at the sentence level, are trained mostly on modern Chinese and fail to fully adapt to the mixed classical–vernacular style of DRC, thus producing semantic and syntactic deviations. Existing studies have introduced PoemBERT(Chihan et al, 2025) , a BERT-based pre-trained model for classical Chinese poetry that integrates sentiment and pinyin embeddings, character-importance-based masking, and dynamic masking strategies; however, existing BERT-based research has so far focused mainly on Chinese classical poetry.

(2) Large language models (LLMs), despite their strength in metaphor comprehension and generation, face issues such as limited context length, semantic drift in long documents, high computational cost, and the lack of end-to-end tooling, making them unsuitable for full-book systematic analysis.(Yanchun, 2024)

To bridge this gap, we develop a full-book character analysis system for modern Chinese classics based on BERT(Jacob et al, 2019). The system performs multi-dimensional automated analysis — including metaphor detection and sentiment assessment — supporting efficient and systematic research on large-scale literary works such as DRC. At the application level, we use this system to identify metaphorical sentences across the entire book and conduct sentiment analysis for different characters. By examining emotional trajectories, we reveal characters’ fates and their varying degrees of acceptance by the novel’s social structure, enabling deeper analysis of character construction and the tension between personal disposition and traditional values.

Method

Using sentences as the basic analytical unit, this study systematically processes metaphor usage and its emotional direction in DRC. The overall workflow consists of four stages: corpus preparation and pre-training, metaphor detection, sentiment positivity scoring, and character- and gender-related semantic annotation.

Figure 1: A Systematic Processing Pipeline for Metaphor Use and Sentiment Evaluation in Dream of the Red Chamber Text (Macro Framework)

Figure 2: A Systematic Processing Pipeline for Metaphor Use and Sentiment Evaluation in Dream of the Red Chamber Text ( Detailed Version)

Corpus Preparation and Pre-training

Since the language of Dream of the Red Chamber (early modern Chinese) differs significantly from modern Chinese, directly applying bert-base-chinese results in semantic drift. We clean all 120 chapters (removing annotations and segmenting sentences) and continue pre-training the base model using a masked language modeling (MLM) objective. This yields HLM-BERT, which more accurately captures classical linguistic patterns and provides a solid foundation for subsequent tasks.

Metaphor Detection

Metaphor detection requires both semantic comprehension and syntactic structure modeling. Building on the SaGE(Shenglong et al, 2021) metaphor detection model, we propose SaGH (Syntax-aware GAT with HLM-BERT), consisting of a semantic module, a syntactic graph module, and a bidirectional gating fusion module, adapted specifically to the mixed classical–vernacular linguistic style of DRC.

Semantic Feature Encoding

HLM-BERT encodes character-level sentence representations, followed by a Transformer encoder and masked mean pooling to obtain 64-dimensional semantic vectors.

Dependency Graph Representation and GAT Encoding

The sentence is parsed into a dependency graph to explicitly model structural relations among words. A Graph Attention Network (GAT) learns syntactic structure, dynamically weighting different dependency relations. Two layers of GAT followed by global mean pooling produce syntactic sentence representation.

Bidirectional Gating Fusion

To dynamically integrate semantic and syntactic information within a unified representation space, we concatenate both feature types, generate symmetric gating signals, and produce enhanced semantic and syntactic representations. The fused vector is passed to a linear softmax classifier.

Training and Evaluation

The training dataset is based on the CCL 2018 Chinese Metaphor Detection Task Dataset, augmented with 1,063 manually annotated sentences from DRC. SaGH achieves a macro-F1 of 88.15%, outperforming the baseline SaGE (77.23%), demonstrating the effectiveness of targeted optimization.

Sentiment Positivity Assessment

To obtain continuous sentiment orientation, we train a five‑class sentiment model initialized with HLM-BERT using the FSPC classical poetry sentiment corpus(Shenglong et al, 2021). The positivity score (0–1) is computed from the weighted probability distribution. This continuous metric supports cross-chapter and cross-character trend analysis.

Findings

The proposed framework proves both feasible and interpretively powerful. Using characters Jia Baoyu and Wang Xifeng as examples, metaphor detection and sentiment analysis reveal the emotional mechanisms driving the divergent fates associated with gender-role inversion.

Jia Baoyu’s and Wang Xifeng’s Emotional Trajectory Under Metaphorical Sentiment

When others describe Baoyu metaphorically, sentiment declines from 0.5004 to 0.3565—reflecting a shift from indulgence to neglect. Conversely, Baoyu’s own metaphor-related sentiment rises from 0.2034 to 0.4388, indicating initial self-suppression under paternal pressure followed by increasing insistence on “emotion”. His eventual monastic departure signifies a voluntary exit from normative masculinity, dissolving the threat his gender nonconformity poses to familial order.

Xifeng shows the opposite pattern. Sentiment in others’ metaphorical descriptions plummets from 0.5155 to 0.3178, while her own metaphor-related sentiment drops from 0.4175 to 0.2668—revealing her collapse from power and social brilliance to isolation. Her “female body & male heart” qualities are tolerated in times of prosperity but condemned in decline, leading to her loss of authority, dignity, and emotional support.

Conclusion: Double Standards of Gender Inversion and Divergent Fates

Baoyu’s rising positivity (0.4388) symbolizes transcendence; Xifeng’s descent (0.2668) symbolizes annihilation. This contrast exposes a deep gender logic in traditional society: male femininity may be aestheticized or spiritualized, while female masculinity is treated as an assault on patriarchal order— punished once its utility fades.

Figure 3: Character Interaction Sentiment Heatmap — Jia Baoyu / Wang Xifeng

Figure 4: Line Chart of Sentiment Positivity Trends Across Chapters in Dream of the Red Chamber — Jia Baoyu / Wang Xifeng

Influences

Full_Book Analytical Tools for Classical Chinese Literature

The system offers large-scale automated metaphor detection and sentiment analysis for the mixed classical and vernacular language of modern Chinese novels, especially for Dream of the Red Chamber, enabling efficient, systematic, and reproducible scholarship.

Expansion of Redology Research Boundaries

Character appreciation is an important component of textual research and is deeply popular among readers, but it has the issue of strong readability while somewhat lacking in depth(Chihan et al, 2025). Automated metaphor-based sentiment trajectories provide refined and deeper insights into character fate, gender politics, and social structures, which solves the problem raised by the society of Dream of the Red Chamber regarding the study of characters in DCR: insufficient depth in appreciation and failure to incorporate social and cultural backgrounds.

Advancement of Digital Humanities

The novel SaGH framework demonstrates how AI techniques can be adapted for classical-language literature, contributing a replicable paradigm for digital humanities research, which can be combined with LLMs for further explorations.

  • Yanchun Yu.(2024): A Study on the Applicability of Large Language Models in Metaphor Identification within Critical Metaphor Analysis.
  • Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova(2019): BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.
  • Shenglong Zhang, Ying Liu, and Yanjun Ma(2021): SaGE: Syntax-aware GCN with ELECTRA for Chinese Metaphor Detection).
  • Chihan Huang and Xiaobo Shen(2025): PoemBERT: A Dynamic Masking Content and Ratio Based Semantic Language Model For Chinese Poem Generation.
  • Zhongqi Shi, Qing Hu, Shuhan Yao(2025): 2024年度中国红学发展研究报告(2024 Annual Report on the Development of Redology in China). Studies on A Dream of Red Mansions .