Abstract
Poetry was a unique literary genre in ancient China as an important way to express sentiments. Chinese ancient poetry not only has simple words, strict meters and rich semantic relationships, but also widely uses rhetorical techniques such as simile and personification, as well as metaphorical means such as allusion and imagery, which makes it difficult to understand their implicit sentiments quickly and accurately. Therefore, this paper attempts to make full use of the semantic features of Chinese ancient poetry text and the knowledge feature of related domains under the guidance of the research paradigm of digital intelligence integration, and based on which, proposed Sentiment Analysis Model of Chinese Ancient Poetry based on Multidimensional Attention (SAMCAP). This model extracts semantic features from Chinese ancient poetry text, meanwhile designs a multidimensional attention to extract the knowledge feature from the knowledge base of Chinese ancient poetry. The recognition of Chinese ancient poetry sentiment is performed by integrating the textual feature and knowledge feature. Comparison experiments on the open ancient poetry corpus verified the effectiveness of the proposed model, and the ablation experiment explored the importance of different knowledge to the sentiment analysis result of Chinese ancient poetry.
1 Introduction
In ancient China, poetry was one of the important ways to express the ancient’s sentiments. During the period from the pre-Qin Dynasty to the Qing Dynasty, lasting for more than 1,000 years, more than 50,000 works of poetry were composed and survived today in China, which recorded the joys and sorrows of the ancient people as well as the changes of an era. In terms of word number, Chinese ancient poetry appears in the form of quatrain, pentameter, heptameter, and miscellaneous. From the Tang Dynasty, these works of poetry were called recent-style poetry and divided into two categories, quintet and heptameter, with quintets in five-character stanzas and heptameters in seven-character stanzas. This paper focuses on the recent-style poetry. As a unique literary genre in ancient China, poetry has simple words, strict meters, and rich semantic relationships, but also widely uses rhetorical techniques such as simile, personification, and metaphorical means such as allusion and types of imagery to implicitly express ancient sentiments. However, this unique organizational structure and the expression habit of Chinese ancient poetry bring great challenges to its sentiment analysis.
With the arrival of the big data era, big data technologies and methodologies have become an important technology paradigm. More and more research has shown that big data technologies and methodologies represented by the deep learning model are suitable for dealing with data with large scale, diverse relationships, and complex structures. Therefore, how to make full use of big data technologies and methodologies for sentiment analysis of Chinese ancient poetry deserves an in-depth discussion. In view of this, this paper highlights the importance of Chinese ancient poetry texts and related domain knowledge for sentiment analysis and proposes using the Sentiment Analysis Model of Chinese Ancient Poetry based on Multidimensional Attention (SAMCAP), based on the introduction of a series of deep learning models and attention mechanisms. The proposed model firstly extracts the semantic features from Chinese ancient poetry texts, and then retrieves the knowledge related to the input text, such as allusion, imagery, radical, and sentiment term, based on constructing a knowledge base of Chinese ancient poetry. Meanwhile, the attention mechanism is introduced to facilitate feature extraction and integration of the textual feature and the knowledge feature of Chinese ancient poetry. Finally, the sentiment tendencies can be determined based on the output of the multidimensional attention. The research of this paper not only improves the sentiment analysis methodological system of Chinese ancient poetry, but also contributes to the creative transformation and innovative development of traditional Chinese culture and promotes the integration of culture and science and technology.
2 Literature Review
Sentiment analysis of Chinese ancient poetry is a special research section of Chinese sentiment analysis, which shares some common characteristics of Chinese sentiment analysis but also requires special research methods because of the aforementioned unique organizational structure and expression habit. Therefore, this paper focuses on the sentiment analysis method of Chinese ancient poetry on the basis of summarizing the related latest achievements so as to lay a solid literature foundation for this paper.
In recent years, there have been a number of achievements in Chinese sentiment analysis. Su et al. (2019) combined the context and objective of Chinese metaphors and built a Chinese metaphor system for sentiment analysis by introducing the Long Short-Term Memory (LSTM) model with attention mechanism for the characteristics of Chinese metaphors, on the basis of Chinese culture knowledge. Liu and Zhao (2023) proposed a Chinese sentiment analysis model by integrating multi-granular semantic features so as to adapt to Chinese special characteristics and sentiment analysis requirements. With Bi-directional Long Short-Term Memory (BiLSTM), attention mechanism, and Recursive Convolutional Neural Network (RCNN) applied in this model, the performance of Chinese sentiment analysis has greatly improved by extracting the radical and lexical features of Chinese characters. Liu and Zhao (2023) firstly utilized Convolutional Neural Network (CNN) to retrieve the sentiment features of Chinese text, then applied Bidirectional Gated Recurrent Unit (BiGRU) afterwards to capture the contextual features, and finally utilized the multi-attention mechanism to acquire the important information related to the sentiment from different dimensions. Elsewhere Huang et al. (2023) proposed the BERT-BiGRU-GANet model for Chinese sentiment analysis. This model firstly used a BERT (Bidirectional Encoder Representations from Transformers) model to vectorize the Chinese text, then used the BiGRU model to analyze the contextual information of the Chinese text, and finally adopted the attention mechanism to highlight the key features that play an important role in Chinese sentiment analysis. In view of the effectiveness of external knowledge for Chinese sentiment analysis, Liao et al. (2022) proposed a multi-polarity attention model with sentimental commonsense. This model merged sentiment information into a generalized knowledge base and integrated sentiment knowledge with textual semantics so as to improve the performance of Chinese sentiment analysis. In addition, Yang et al. (2023) proposed a Chinese sentiment analysis model that combined character granularity features and word granularity features. This model tried to acquire the multi-level and multi-granularity semantic information so as to improve the performance of Chinese sentiment analysis. Wang et al. (2023) proposed a hybrid model of CNN and BiLSTM to extract multi-level and multi-scale features. This model obtained the phrase-level and sentence-level features separately by using CNN with different convolutional kernel sizes and BiLSTM with different scales. A multi-level feature fusion method was introduced to integrate the phrase-level and sentence-level features to form the multi-level joint features.
More and more researchers are focusing on the sentiment analysis of Chinese ancient poetry. Although still in the initial stage with relatively rare achievements, these achievements are enlightening and attractive for future research. Zhang et al. (2023) proposed a sentiment analysis algorithm for Tang poetry, taking advantage of both TF-IDF and FP-Growth algorithms for feature extraction and word-level relation mining respectively. Tang et al. (2020) applied CNN and GRU for feature extraction of Tang poetry text and introduced multi-channel processing model for feature extraction of sentences on the basis of the special structural characteristics of Tang poetry. Li and Li (2018) proposed a sentimental characteristics extracting algorithm making use of TF-IDF’s good support for feature extraction and FP-growth algorithm’s advantage in mining relationships between words. Lin et al. (2022) proposed a joint loss function with the line loss and the character loss and adopted a self-training strategy to improve the efficiencies of Chinese poetry sentiment analysis. Moreover, in order to solve the problems of sparse features and the lack of modern Chinese corpus, Wu et al. (2016) proposed a transfer learning model based on the short-text feature extension for Tang poetry sentiment analysis. This model expanded the ancient poetry features based on the frequent word pairs, utilized the transfer learning method to train the sentiment classifiers, and discriminated the sentiment tendency of Tang poetry based on the voting strategy. Li et al. (2021) proposed a method of analyzing the metrical poetry sentiment based on the integrated capsule network by using the integrated capsule network model training through different rhythms with the word count rule. It solved the sentiment analysis problem of the metrical poetry due to the implicit sentiment features and the overly compact semantics.
The following conclusions can be drawn based on summarizing the literature of Chinese sentiment analysis, especially on Chinese ancient poetry.
The effectiveness of sentiment analysis depends on the feature extraction capability of the model. Deep learning models emerged in recent years and demonstrated good capabilities of feature extraction, which explains why deep learning models are popular in sentiment analysis. However, most of this research borrow the existing models, which are not dedicated for ancient Chinese poetry texts, leaving the relevance and applicability to be further explored in this area.
Non-intuitive Chinese texts, especially Chinese ancient poetry texts, have some distinctive traits with the sentiment expression embedded in the words, especially using the rhetorical devices to express sentiment implicitly, such as with metaphor and simile and sometimes using allusion and imagery as well. How to discriminate the implicit sentiment is the key to improving the performance of ancient Chinese poetry sentiment analysis.
Existing research often adopts a data-driven research paradigm to Chinese sentiment analysis particularly on ancient Chinese poetry. However, the reliability and accuracy of training data are not guaranteed, and there potentially exists some errors in the sentiment analysis result. In recent years, the research paradigm of digital-intelligence integration has been popular and widely used, with better practical results achieved. Therefore, it is worthwhile to further discuss whether domain knowledge is suitable to improve the performance of Chinese ancient poetry sentiment analysis.
This paper introduces the research paradigm of digital-intelligence integration. The implicit sentiment, such as allusion sentiment and imagery sentiment, Chinese character’s radical sentiment, and the explicit sentiment term, were taken into consideration, and a model based on the multi-dimensional attention has been proposed.
3 Model Description
As shown in Figure 1, the framework of SAMCAP consists of four parts, including text representation, knowledge retrieval, knowledge integration, and result output. The text representation module consists of the pre-training model GuwenBERT, so as to extract the textual feature from Chinese ancient poetry texts. The knowledge retrieval module is used to retrieve the knowledge of allusion, imagery, radical, and sentiment term from the knowledge base of Chinese ancient poetry, based on which to extract the knowledge feature. The knowledge integration module implements the attention mechanism for feature extraction and integration of the textual feature and the knowledge feature. The result output module determines the sentiment of Chinese ancient poetry.

The research framework.
3.1 Text Representation Module
The pre-training model GuwenBERT is used in the text representation module to extract the semantic features of the Chinese ancient poetry texts, so as to form the textual feature of Chinese ancient poetry.
The GuwenBERT model[1] is a pre-trained model of RoBERTa by the Chinese ancient literature corpus of Daizhige. The training corpus of this model covers several kinds of Chinese ancient literature with 1.7 billion words in total. The workflow of this model is shown in Figure 2, where TE, SE, and PE respectively denote token embedding, segment embedding, and position embedding. The embedding layer encodes the Chinese ancient poetry text and vector representation in terms of token embedding, segment embedding, and position embedding. Token embedding splits Chinese ancient poetry texts into words and converts them into a vector with a fixed dimension. Segment embedding encodes Chinese ancient poetry texts as sentences. Position embedding identifies the sequential order of the words composing the poetry. The above three kinds of vectors form the input vectors of the GuwenBERT model, migrating some linguistic features of modern Chinese to Chinese ancient poetry texts with the help of RoBERTa, so as to effectively capture the semantic features of Chinese ancient poetry text. The GuwenBERT model is used to extract features from the input vectors and then form the textual feature of Chinese ancient poetry pt = {x1, x2, …, x t }.

The framework of Guwen-BERT.
3.2 Knowledge Retrieval
The sentimental tendency of Chinese ancient poetry is expressed intuitively between the lines of Chinese ancient poetry and indirectly by the allusion and imagery in the poetry. In addition, the Chinese characters consisting of Chinese ancient poetry have certain sentimental direction, such as “忄” which is the Chinese character of “怕 (fear),” “恨 (hate)”, “怨 (resentment),” and “怒 (wrath),” which are related to psychological activity and sentimental expression as they are prone to negative sentiment in Chinese ancient poetry. Therefore, the knowledge retrieval module attempts to utilize the knowledge of Chinese ancient poetry to guide the process of Chinese ancient poetry sentiment analysis. This module has two main functions: knowledge base construction and knowledge retrieval. The knowledge base of Chinese ancient poetry includes allusion, the imagery base, the Chinese character’s radical base, and the sentiment term base.
To construct the allusion and imagery base, the combination of Internet search and manual collation is used to obtain the allusion and imagery information. Then the correlation analysis is conducted to construct the mapping relationships between the above two kinds of information and their implicit sentiments. Meanwhile, the knowledge graph technology is later applied to construct the allusion and imagery base, covering allusion and imagery and their sentimental tendencies.
To retrieve the knowledge of allusion and imagery, as well as their sentimental tendencies, the toolkit Harvesttext[2] is used to extract the allusion entity and imagery entity from the Chinese ancient poetry text, by loading the allusion and imagery knowledge from the allusion and imagery base. With the help of entity linking, the mapping relationship between the knowledge of allusion and its connotation, as well as the knowledge of imagery and its connotation, can be established. Through querying the knowledge base of Chinese ancient poetry, the implicit sentimental tendency in the allusion connotation and the image connotation can be obtained, meaning the sentiment of the allusion knowledge and imagery knowledge are available. The allusion and imagery sentiment are denoted as Alt-Smt and Im-Smt respectively. For example, in the text of “海外孤忠泣鬼神|丹心为国竟忘身|大星遽陨年难假|天意偏摧社稷臣” [The Prince of Yanping fight a lone battle abroad, and his heroic deeds moved heaven and earth, even ghosts and gods. | He devoted everything to his country, even sacrificing his life. | The sudden death of such outstanding hero caused significant losses to the country. | It seems the heaven intended to destroy the pillars of his country], the allusion entity is “丹心” [a loyal heart], which means loyalty to country, the mapping relationship between the allusion knowledge and its connotation is {丹心:为国捐躯者的忠贞品格} [A loyal heart: The loyal character of those who sacrifice themselves for their countries], and the mapping relationship between the allusion connotation and its implicit sentiment is {为国捐躯者的忠贞品格:敬重和怀念} [The loyal character of those who sacrifice themselves for the countries: Respect and cherish]. It can be concluded that the mapping relationship between the allusion knowledge and its implicit sentiment is {丹心:敬重和怀念} [A loyal heart: Respect and cherish]. Similarly, in the text of “定知花发是归期|不奈归心日日归|风雪岂知行客恨|向人更作落花飞” [I was certain that when the flowers bloomed, it would be the day I returned home. | However, my exception of coming back home grew with each passing day. | How could the wind and snow understand the regret of wanderers? | The snow drifted towards wanderers like falling flowers.], the allusion entity is “落花” [falling flowers], the mapping relationship between the imagery knowledge and its connotation is {落花:慨叹年华的逝去} [Falling flowers: Lamenting the passage of time], and the mapping relationship between the imagery connotation and its implicit sentiment is {慨叹年华的逝去:喟叹和哀愁} [Lamenting the passage of time: Grief and sorrow]. The mapping relationship between the imagery knowledge and its implicit sentiment can be concluded as {落花:喟叹和哀愁} [Falling flowers: Grief and sorrow].
The construction process of the Chinese character’s radical base is as follows. Firstly, the text of Chinese ancient poetry is decomposed word by word, so as to generate the Chinese character set. Secondly, according to the mapping relationships of Chinese radicals in Xinhua Dictionary, the radical of each Chinese character is obtained. Finally, with the help of the “Commonly Used Radical Profile” provided by textual experts, the connotation and sentimental tendency of Chinese radicals are both annotated and the Chinese character’s radical base is constructed, including the relationship among Chinese character, radical, connotation, and sentimental tendency. The process of retrieving Chinese characters’ radical bases is as follows. Firstly, the Chinese radical is extracted from the Chinese ancient poetry text word by word. Secondly, the sentimental tendency of Chinese character in the poetry text can be obtained, denoted as Rd-Smt, by matching the sentimental tendency of the corresponding radicals in the Chinese character’s radical base. Particularly, as some Chinese radicals do not have sentimental tendencies, the knowledge retrieval module does not process these Chinese characters and their radicals.
The construction process of the sentiment term base is as follows. The Weiciyun[3] is used to extract the sentiment terms from Chinese ancient poetry texts, and the sentiment term base can be constructed by manual processing, which includes three kinds of sentiments: positive, neutral, and negative. The process of retrieving the sentiment terms is as follows. Firstly, the sentiment terms are extracted and de-duplicated from Chinese ancient poetry text by Weiciyun.2 Secondly, the sentiment tendencies of above terms can be obtained by matching the strategy in the sentiment term base, denoted as Smt-Term. For example, in the text of “漱罢寒泉弄月明|浩然风露欲三更|曲曲阑干畔踟躇久|静听空廊络纬声” [I had finished washing, walked to the spring, and enjoyed the beautiful moonlight. | The night was fresh and peaceful, while it was so late at night. |I wandered by the edge of railing for a long time. |I quietly listened to the sound of crickets in the empty corridor.], the mapping relationship between the sentiment term and its sentiment tendency can be obtained as {浩然:积极} [Fresh and peaceful: Positive], {踟躇:消极} [Wander: Negative], and {空廊:中性} [Empty corridor: Neutral], with the help of matching strategy.
3.3 Knowledge Integration
The knowledge integration module consists of knowledge representation and knowledge integration. In the process of knowledge representation, the knowledge of allusion, imagery, radical, sentiment term, and their sentimental tendencies, respectively denoted as Alt-Smt, Im-Smt, Rd-Smt, Smt-Term, are fed into the model. The Chinese pre-training model bert-base-Chinese,[4] an improved BERT model, is then utilized to extract the features of the above inputs and the corresponding knowledge features can be denoted as as, is, rs, and st, where the bert-base-Chinese is trained on a large-scale Chinese corpus and has good ability of capturing the syntactic structure and semantic feature of Chinese text particularly. Meanwhile, the textual feature of Chinese ancient poetry pt is also fed into the model. In the process of knowledge integration, a multidimensional attention is designed to calculate the importance and contribution of above inputs, including as, is, rs, st, and pt, to the Chinese ancient poetry sentiment analysis. Finally, the outputs of multidimensional attention are integrated to form the knowledge description of Chinese ancient poetry.
Although as many works of Chinese ancient poetry as possible are collected while processing the knowledge base, it is difficult, if not impossible, to collect all Chinese ancient poetry to construct a complete knowledge base. In addition, there inevitably are some errors or mismatching issues during the process of knowledge retrieval. Therefore, this paper tries to introduce an attention mechanism to reduce these negative impacts. Inspired by vanilla attention (Bahdanau et al. 2015) presented by Bahdanau, a multidimensional attention is proposed, with the advantage of establishing the mapping relationship of organizational structure between the target and source sentence. Five kinds of attention functions are designed based on the vanilla attention, including Poetry Text Attention (Pt-attention), Allusion Sentiment Attention (As-attention), Imagery Sentiment Attention (Is-Attention), Radical Sentiment Attention (Rs-Attention), and Sentiment Term Attention (St-Attention), respectively denoting the importance and contribution of the sentiments contained in the textual feature of Chinese ancient poetry and the knowledge feature of allusion, imagery, radical, and sentiment term to the Chinese ancient poetry sentiment analysis, which can be calculated as follows:
where α i , β i , γ i , δ i , ε i respectively denote the ith attention weights of the sentiments in the Chinese ancient poetry text and the knowledge of allusion, imagery, radical, and sentiment term. The larger the values of α i , β i , γ i , δ i , ε i , the greater the contribution of the ith feature to the final results. tanh(•) is a nonlinear activation function with the hyperbolic tangent of transform. pt_w i , as_w i , is_w i , rs_w i , st_w i are the weight matrices and b i is the bias vector. softmax(•) function is used to normalize the attention weights.
Equations (6)–(10) are used to calculate the semantic vectors F pt , F as , F is , F rs , F st containing the sentiments of the textual feature of Chinese ancient poetry and the knowledge feature of allusion, imagery, radical, and sentiment term. In order to improve the performance of sentiment analysis, the semantic vectors can be integrated with the help of the last layer of multilayer perceptron, and the integration result is the Chinese ancient poetry encoding a.
Where the weights of above five kinds of semantic vectors can be calculated by
3.4 Result Output
The result output module is to produce the sentiment analysis result, with workflow shown in Figure 3.

The workflow diagram of result output.
Firstly, the Chinese ancient poetry encoding a is fed to the fully connected layer. Secondly, the probability output a p is calculated by using the softmax(•) function for normalization. Lastly, the argmax(•) function is used to calculate the output with the largest probability as the sentiment analysis result of Chinese ancient poetry y. The above workflow can be calculated by equations (13)–(14).
Where W and b respectively denote the weight matrix and the bias of the fully connected layer, softmax(·) is the normalization function and argmax(·) is the function with the maximum output probability.
4 Experimental Design and Analysis
4.1 Experimental Corpus
The experimental corpus used in this paper is the Chinese ancient poetry corpus FSPC (Fine-grained Sentimental Poetry Corpus) maintained by the Natural Language Processing Research Center of Tsinghua University (Chen et al. 2019). This corpus consists of 5,000 works of Chinese ancient poetry from several Chinese dynasties and dominated by those from the Tang and Song dynasties, which can be classified into five classes: negative, implicit negative, neutral, implicit positive, and positive. In this paper, the negative and implicit negative are merged for convenience, as are the implicit positive and positive. Three resulting sentiments, including negative, neutral, and positive, are used in the experiments and denoted as −1, 0, and 1 respectively. The distribution of Chinese ancient poetry with different sentiments is shown in Figure 4. The experimental corpus is preprocessed to facilitate the model training. Firstly, the experimental corpus is randomly disrupted to ensure that the corpus distribution of different sentiments is as consistent as possible. Secondly, the corpus is divided into training set, validation set, and test set by the ratio of 3:1:1, in which the training set is used to train the model, the validation is set to verify the training effectiveness, and the test is set to test the performance of the model.

Distribution of Chinese ancient poetries with different sentiments.
4.2 Comparative Experiments
4.2.1 Experimental Models
In order to verify the effectiveness of the proposed model, several models are introduced for comparative experiments.
BiLSTM: BiLSTM contains two LSTM models in opposite directions.
BiLSTM + SA: BiLSTM + SA adds self-attention mechanism to BiLSTM.
XLNetbase (Yang et al. 2019): XLNetbase is a generalized auto regressive pre-training model based on Permutation Language Modeling (PLM). In this paper, the Chinese-xlnet-base model is used for Chinese ancient poetry texts (Li et al. 2023).
gMLPbase (Liu et al. 2021): gMLPbase is a gated Multilayer Perceptron (gMLP) with a gating mechanism.
GuwenBERTbase: [5]GuwenBERTbase is a special version of the RoBERTa model, which trains on a large-scale Chinese ancient corpus.
SACAP: the model proposed in this paper.
4.2.2 Parameters
The cross entropy loss function with a mask is used to train the experimental models, with AdamW as the optimizer and 20 rounds of training. F1 value is used to evaluate the experimental results. The parameters of the experimental models are shown in Table 1.
Parameters of experimental models.
Model | batch_size | learning_rate | dropout | hidden_dim |
---|---|---|---|---|
BiLSTM | 64 | 2e-4 | 0.6 | 768 |
BiLSTM + SA | 64 | 2e-4 | 0.6 | 768 |
XLNetbase | 64 | 2e-5 | 0.6 | 768 |
gMLPbase | 64 | 2e-5 | 0.6 | 768 |
GuwenBERTbase | 64 | 2e-5 | 0.6 | 768 |
SACAP | 16 | 1e-5 | 0.6 | 768 |
4.2.3 Analysis of Experimental Results
The results of the Chinese ancient poetry sentiment analysis are obtained by running the experimental models on the experimental corpus sequentially, as recorded in Table 2.
Comparative experiment results of experimental models.
Model | F1 |
---|---|
BiLSTM | 0.5143 |
BiLSTM-SA | 0.6022 |
gMLPbase | 0.6479 |
XLNetbase | 0.7035 |
GuwenBERTbase | 0.8585 |
SACAP | 0.9103 |
It can be seen from Table 2 that SACAP model has the highest F1 value of 0.9103, followed by GuwenBERTbase, XLNetbase, gMLPbase, BiLSTM-SA, and BiLSTM in this order. The causes of the comparative experimental results are analyzed as follows.
The BiLSTM model is good at extracting contextual features of Chinese text, but less effective for Chinese ancient poetry text. There could be two main reasons for this. On the one hand, the length of Chinese ancient poetry text is generally short, which is not conducive enough to establish contextual relationships by the BiLSTM model. On the other hand, the sentiment expression in Chinese ancient poetry text tends to be implicit, as it uses rhetorical techniques such as simile and personification as well as metaphorical means such as allusion and imagery. This implicit expression leads to a difference between the extracted contextual feature and the actual feature.
The F1 value of the BiLSTM-SA model is 0.0879 higher than that of the BiLSTM model. It can be seen from above experimental result that the introduction of the self-attention mechanism contributes to improve the performance of Chinese ancient poetry sentiment analysis. The self-attention mechanism is good at capturing the intrinsic connection features of Chinese ancient poetry texts, which is an important supplement to its contextual feature. This in turn enhances the feature extraction ability of Chinese ancient poetry texts, and therefore improves the performance of Chinese ancient poetry sentiment analysis.
The F1 value of the gMLPbase model is 0.1336 and 0.0457 higher than those of BiLSTM and BiLSTM-SA respectively, because gMLPbase has a deeper and more complex structure and sufficient training can enable the model to learn more semantic features. Some of these features, however, cannot be learned by BiLSTM and BiLSTM-SA.
The F1 value of the XLNetbase model is 0.0556 higher than that of the gMLPbase model, due to the following two reasons. On the one hand, the XLNetbase model solves the problem neglected by the BERT model that ignores the dependency relationship between the masked sentences. On the other hand, it overcomes the problem that the auto regressive model cannot utilize the contextual feature of the experimental corpus. The XLNetbase model tries to solve the above problems and it has good learning ability. It not only extracts the semantic features of Chinese ancient poetry texts but also further captures the contextual feature and thus has a better performance of Chinese ancient poetry sentiment analysis.
The F1 value of the GuwenBERTbase model is 0.155 higher than that of the XLNetbase model, because the GuwenBERTbase model is based on the continue training technique. The GuwenBERTbase model makes full use of the training parameters of RoBERTa and the large-scale ancient Chinese corpus, and transfers the linguistic features from modern Chinese to ancient Chinese. Since modern Chinese is more efficiently annotated than ancient Chinese, the GuwenBERTbase model has some advantages on ancient Chinese processing, which helps to improve the performance of Chinese ancient poetry sentiment analysis.
The SACAP model has the highest F1 value, which is 0.396, 0.3081, 0.2624, 0.2068, and 0.0518 higher than that of BiLSTM, BiLSTM-SA, gMLPbase, XLNetbase, and GuwenBERTbase, respectively. The SACAP model takes advantage of GuwenBERT, BiLSTM, and attention mechanism and makes use of both explicit and implicit features of Chinese ancient poetry text to conduct sentiment analysis. Specifically, in the process of text representation, Chinese ancient poetry text can be processed by GuwenBERT. This process makes full use of the above model’s advantage, and the textual feature can be precisely described by the implicit feature of Chinese ancient poetry text. Meanwhile, extracting and utilizing the explicit and implicit features of Chinese ancient poetry text is useful for sentiment analysis, in which the explicit feature can be extracted from the sentiment term of Chinese ancient poetry and the implicit feature can be extracted from the poetry text, allusion, imagery, and radical.
In order to test the effectiveness of the SACAP model in Chinese ancient poetry sentiment analysis, the GuwenBERTbase model is selected for the comparative experiment. The experimental results are shown in Table 3.
Comparative experiment results of GuwenBERTbase and SACAP (F1).
Model | Negative | Neutral | Positive |
---|---|---|---|
GuwenBERTbase | 0.9006 | 0.7595 | 0.8320 |
SACAP | 0.9202 | 0.8811 | 0.9050 |
It can be seen from Table 3 that in terms of overall performance, the F1 values of SACAP are much higher than those of GuwenBertbase on the experimental corpus with different sentiments. Specifically, the F1 values of SACAP for recognizing negative, neutral, and positive sentiment are 0.0196, 0.1216, and 0.0730 higher than those of GuwenBertbase, respectively. The values of these two models on negative sentiment analysis are close to each other and both arrive at above 0.9. This is due to the fact that Chinese ancient poetry text tends to present the sentiment term with clear negative sentiment indication in context, which makes its sentimental tendency easier to recognize. The performance of these two models for neutral and positive sentiments varies greatly, with a relatively better performance for positive sentiment. The main reasons are as follows. Firstly, some Chinese ancient poetry appears as sentiment terms with positive sentiment and therefore their sentimental tendencies are easier to recognize. Secondly, the sentiment of Chinese ancient poetry is closely related to the allusion and imagery mentioned in the poetry. Thirdly, The Chinese character’s radical is helpful for understanding the sentimental tendency of Chinese ancient poetry. Therefore, both models have good performances on positive sentiment analysis, but the SACAP model performs much better. Compared to the negative and positive sentiments, both models have lower performances in recognizing the neutral sentiments. The F1 value of GuwenBERTbase on recognizing the neutral sentiment is 0.1411 and 0.0725 lower respectively than that of recognizing the negative and positive sentiments. The F1 value of SACAP on recognizing the neutral sentiment is 0.0391 and 0.0239 lower respectively than that of negative and positive sentiments. The main reason is that the expression of neutral sentiment in Chinese ancient poetry is usually more implicit. In some cases, there exist some allusions, imageries, or sentiment terms in Chinese ancient poetry, as well as some deviations between the sentimental tendency and the actual sentiment, which leads to the misclassification of Chinese ancient poetry sentiment.
4.3 Ablation Experiment
In order to verify the impact of various knowledge on Chinese ancient poetry sentiment analysis, an ablation experiment is conducted with the same parameters, and the experimental results are recorded in Table 4, where PT, AS, IS, RS, and ST respectively denote the poetry text, allusion sentiment knowledge, imagery sentiment knowledge, and radical sentiment knowledge, while the sentiment term “√” denotes that the knowledge was adopted and “×” indicates that the knowledge was not adopted.
Ablation experimental results.
Model | PT | AS | IS | RS | ST | F1 |
---|---|---|---|---|---|---|
SACAP-PT | √ | × | × | × | × | 0.8585 |
SACAP-AS | × | √ | × | × | × | 0.8702 |
SACAP-IS | × | × | √ | × | × | 0.8830 |
SACAP-RS | × | × | × | √ | × | 0.8893 |
SACAP-ST | × | × | × | × | √ | 0.9018 |
SACAP | √ | √ | √ | √ | √ | 0.9103 |
In Table 4, no external knowledge is introduced to the SACAP-PT model, which means the SACAP model consists of only a text representation module and result output module. The most important part is the text representation module, which consists of GuwenBERT. It can be seen from Table 4 that the F1 value of SACAP-PT is 0.8585, which is equal to that of GuwenBERT. The knowledge of allusion sentiment and imagery sentiment are respectively introduced to the SACAP-AS model and the SACAP-IS model, with their F1 values 0.0117 and 0.0308 higher than those of the SACAP-PT model. The main reason of the above results is as follows. The allusion and the imagery in Chinese ancient poetry are closely related to the poet’s situation and expression of views. The performance of Chinese ancient poetry sentiment analysis can be improved by analyzing the sentimental tendencies of allusion and imagery. The Chinese character’s radical is introduced to the SACAP-RS model, with its F1 value slightly higher than those of SACAP-AS and SACAP-IS. It can be inferred that the sentiment in the radical contributes to the improvement of sentiment analysis efficiency. Only the sentiment term is introduced to the SACAP-ST model, and its F1 value is 0.0433, 0.0316, 0.0188, and 0.0125 higher than those of SACAP-PT, SACAP-AS, SACAP-IS, and SACAP-RS respectively. The F1 value of the SACAP model is only 0.0085 higher than that of the SACAP-ST model, which is mainly due to the fact that the poetry text and the knowledge of allusion, imagery, and radical belongs to the implicit knowledge, which indirectly expresses the sentiment of Chinese ancient poetry. Meanwhile, the sentiment term is the explicit knowledge that directly reflects the sentimental tendency of Chinese ancient poetry. It can be seen from above experimental results that the explicit knowledge plays a much more important role on Chinese ancient poetry sentiment analysis compared with implicit knowledge.
5 Limitations and Future Plans
Although the SACAP model performs well on the sentiment analysis of Chinese ancient poetry, there are some limitations. Firstly, the ancient Chinese literary genres are rich and diverse, such as poetry, ci and lyric verses, with their language style and organization structure entirely different, which poses a challenge to the generalization ability of SACAP. The poetry can be divided into ancient poetry and recent-style poetry. The ancient poetry has a relatively free structure, little rhythmic restriction, and a simple and natural language style. The recent-style poetry has a rigorous structure, emphasizes antithesis, tone and rhyme, the language of which is concise and rhythmic, and conveys profound sentiments and thoughts through concise lines. The ci has unique styles, such as fixed word count, combination of long and short sentences, and regulated tones, which make it different from the recent-style poetry. The lyric verses, especially in the Yuan Dynasty, have a close connection with ci. Although there exist some differences in phonology, it adopts a rhythmic structure of long and short sentences. Its characteristics are its popularity, oral-expression, and free-structure (Wang 2015). In this paper, the training corpus of SACAP is mainly from the recent-style poetry of Tang and Song dynasties, and it can be inferred that there may exist some difficulties in dealing with other genres of ancient Chinese literature such as ci and lyric verses, the combination of long and short sentences in ci, and the oral expression of lyric verses, leading to the poor performance of sentiment analysis. Meanwhile, the imagery and allusion in Chinese ancient poetry are usually interwoven with specific objects and the poet’s sentiments, which not only record the poet’s sentiments and thoughts but are known for their implicit, subtle, and concise characteristics (Zhu 2000). The implicit knowledge contains rich cultural background and historical knowledge, which increases the complexity of sentiment analysis. Therefore, it needs the integration of deep semantic understanding and cross-domain knowledge so as to effectively recognize and utilize the implicit knowledge, which puts forward a greater demand on the model.
Future research can be conducted from the following two aspects so as to solve the above problems. One is to analyze the correlation and difference among the ancient Chinese literary genres, such as poetry, ci, and lyric verses, based on which research can be conducted on the applicability of the model. Transfer learning is an important machine learning method that allows a model to learn one task and then transfer to another task, namely the target task, resulting in a good performance in the target task. Therefore, transfer learning can be introduced to the sentiment analysis of Chinese ancient poetry in the future, in which the model trained on the poetry corpus can be applied to the corpora of ci and lyric verses with minor modification. The construction of the above model is based on the clear understanding of the correlation and difference among these ancient Chinese literary genres. The difficulty lies in how to fine tune the model on the target task. The other is to further explore the language characteristics and expression habits of Chinese, especially ancient poetry, and fully utilize existing ancient knowledge bases, so as to improve the semantic understanding ability of the model. The implicit knowledge such as allusion, imagery, and radical, as well as the explicit knowledge, such as the sentiment term, are both taken into consideration in this paper. However, the statistical characteristics of ancient Chinese poetry are ignored. Until now, there exist few related research studies and, therefore, more attention should be paid to statistical research in the future, especially research on the writing habit, knowledge citation, and sentimental expression to the positive, neutral and negative sentiments, which may play an important role in improving the sentiment analysis performance of Chinese ancient poetry.
6 Conclusions
Poetry is one of the important ways to express ancient sentiment. The special organizational structure and expression habit of Chinese ancient poetry lead to the poor performance in its sentiment analysis. In view of this, this paper utilizes both the textual feature and the knowledge feature of Chinese ancient poetry to improve the efficiencies of Chinese ancient poetry sentiment analysis. Based on the above analysis, this paper proposes the Chinese ancient poetry sentiment analysis method based on the multi-dimensional knowledge attention mechanism by integrating the textual feature and knowledge feature. The experimental results on the Chinese ancient poetry corpus FSPC show that compared with the experimental models, such as GuwenBERTbase, XLNetbase, gMLPbase, BiLSTM-SA, and BiLSTM, the SACAP model has the highest F1 value of 0.9103. The results of the ablation experiment show that compared with the poetry text and the implicit knowledge such as allusion, imagery, and the radical, the explicit knowledge, such as the sentiment term, plays a much more important role in Chinese ancient poetry sentiment analysis.
Funding source: Key Project on Interpreting CPC's 20th National Congress Spirit of the National Social Science Fund of China
Award Identifier / Grant number: 23AZD047
-
Research funding: This research was supported by the Key Project on Interpreting CPC’s 20th National Congress Spirit of the National Social Science Fund of China (Project No. 23AZD047).
References
Bahdanau, D., K. Cho, and Y. Bengio. 2015. “Neural Machine Translation by Joint Learning to Align and Translate.” In Proceedings of the 3rd International Conference on Learning Representations, 1–15. USA, San Diego: International Conference on Learning Representations.Search in Google Scholar
Chen, H., X. Y. Yi, M. S. Sun, W. H. Li, C. Yang, and Z. P. Guo. 2019. “Sentiment-controllable Chinese Poetry Generation.” In Proceedings of the 28th International Joint Conference on Artificial Intelligence, 4925–31. China: Macao.10.24963/ijcai.2019/684Search in Google Scholar
Huang, S. F., C. H. Liu, and Y. L. Zhang. 2023. “Chinese Text Sentiment Analysis Based on BERT-BiGRU Fusion Gated Attention.” American Journal of Computer Science and Technology 6 (2): 50–6. https://doi.org/10.11648/j.ajcst.20230602.11.Search in Google Scholar
Li, G., and J. Li. 2018. “Research on Sentiment Classification for Tang Poetry Based on TF-IDF and FP-Growth.” In Proceedings of the 3rd Advanced Information Technology, Electronic and Automation Control Conference, 630–4. Chongqing, China: IEEE.10.1109/IAEAC.2018.8577715Search in Google Scholar
Li, H. C., J. W. Wang, Y. T. Lu, H. D. Zhu, and J. M. Ma. 2023. “Chinese Multi-Category Sentiment of E-Commerce Analysis Based on Deep Learning.” Electronics 12 (20): 4259. https://doi.org/10.3390/electronics12204259.Search in Google Scholar
Li李晖, H., T. Y. Zhang 张天垣, and S. Y. Jin 金纾羽. 2021. “Social Emotional Mining in Ancient Chinese Metrical Poetry” 古代中国格律诗中的社会情感挖掘.” Computer Engineering and Application计算机工程与应用 57 (7): 171–7. https://doi.org/10.3778/j.issn.1002-8331.2001-0135.Search in Google Scholar
Liao, J., M. Wang, X. Chen, S. G. Wang, and K. Zhang. 2022. “Dynamic Commonsense Knowledge Fused Method for Chinese Implicit Sentiment Analysis.” Information Processing & Management 59 (3). https://doi.org/10.1016/j.ipm.2022.102934.Search in Google Scholar
Lin, Y., M. Cheng, and L. Liu. 2022. “Joint Learning and Self-Training for Poetry Sentiment Recognition.” In Proceedings of the 12th International Conference on Electronics Information and Emergency Communication, 272–5. Beijing, China: IEEE.10.1109/ICEIEC54567.2022.9835055Search in Google Scholar
Liu, H. X., Z. H. Dai, D. So, and Q. V. Li. 2021. “Pay Attention to MLPs.” Advances in Neural Information Processing Systems 34: 9204–15. https://doi.org/10.48550/arXiv.2105.08050.Search in Google Scholar
Liu, Z. B., and W. J. Zhao. 2023. “Chinese Sentiment Analysis Model by Integrating Multi-Granularity Semantic Features.” Data Technologies and Applications 57 (4): 605–22. https://doi.org/10.1108/DTA-10-2022-0385.Search in Google Scholar
Su, C., J. Li, Y. Peng, and Y. Chen. 2019. “Chinese Metaphor Sentiment Computing via Considering Culture.” Neurocomputing 352 (4): 33–41. https://doi.org/10.1016/j.neucom.2019.03.087.Search in Google Scholar
Tang, Y. R., X. M. Wang, P. Qi, and Y. Su. 2020. “A Neural Network-Based Sentiment Analysis Scheme for Tang Poetry.” In Proceedings of 16th International Conference on Wireless Communications and Mobile Computing, 1783–8. Limassol, Cyprus: IEEE.10.1109/IWCMC48107.2020.9148542Search in Google Scholar
Wu吴斌, B., J. Ji吉佳, L. Meng 孟琳, C. Shi 石川, H. D. Zhao, 赵惠东, and Y. Q. Li 李仪清. 2016. “Transfer Learning Based Sentiment Analysis for Poetry of the Tang Dynasty and Song Dynasty” 基于迁移学习的唐诗宋词情感分析.” Electronic Journal电子学报 44 (11): 2780–7. https://doi.org/10.3969/j.issn.0372-2112.2016.11.030.Search in Google Scholar
Wang汪林, L., Z. Q. Mon 蒙祖强, and L. N. Yang 杨丽娜. 2023. “Chinese Sentiment Analysis Based on CNN-BiLSTM Model with Multilevel Multiscale Feature Extraction” 基于多级多尺度特征提取的CNN-BiLSTM模型的中文情感分析.” Computer Science计算机科学 50 (5): 248–54. https://doi.org/10.11896/jsjkx.220400069.Search in Google Scholar
Wang, L. 王. 力. 2015. Chinese Prosody” 汉语诗律学. Zhonghua Book Company中华书局. http://www.zhbc.com.cn/zhsj/pad/book/bookinfo.html?bookid=14552 (accessed September 18, 2024).Search in Google Scholar
Yang, Z. L., Z. H. Dai, Y. M. Yang, J. Carbonell, R. R. Salakhutdinov, and Q. V. Le. 2019. “XLNet: Generalized Autoregressive Pre-training for Language Understanding.” In Proceedings of the 32th Annual Conference on Neural Information Processing Systems, 5754–64. Vancouver, Canada.Search in Google Scholar
Yang杨春霞, C. X., S. C. Yao 姚思诚, and J. J. Song 宋金剑. 2023. “A Chinese Sentiment Analysis Model Fusing Word Information.” 一种融合字词信息的中文情感分析模型. Computer Engineering and Science计算机工程与科学45 (3): 512–9. https://doi.org/10.3969/j.issn.1007-130X.2023.03.017.Search in Google Scholar
Zhang, L. L., Y. D. Wu, Q. K. Chu, P. Li, G. J. Wang, W. H. Zhang, Y. Qiu, and Y. Li. 2023. “SA-Model: Multi-Feature Fusion Poetic Sentiment Analysis Based on a Hybrid Word Vector Model.” Computer Modeling in Engineering and Sciences 137 (1): 631–45. https://doi.org/10.32604/cmes.2023.027179.Search in Google Scholar
Zhu, H. 2000. “A Comparative Study on Imagery in Chinese and English Poetry.” Comparative Literature: East & West 1 (1): 106–14. https://doi.org/10.1080/25723618.2000.12015249.Search in Google Scholar
© 2024 the author(s), published by De Gruyter, Berlin/Boston
This work is licensed under the Creative Commons Attribution 4.0 International License.
Articles in the same Issue
- Frontmatter
- Factors Influencing the Adoption of Green Libraries for Environmental Sustainability: A Systematic Literature Review
- Dimensions of the Ukrainian War in British Press: A Topic Modeling Approach
- Library Leadership in Minority Serving Institutions: Investigating the Backgrounds of MSI Library Directors
- Characteristics of OA Diamond Journal Publishing in Non-English-Speaking Countries
- Aging-Related Information Needs and Barriers Experienced by LGBT+ Older Adults
- Graduate Education in China Meets AI: Key Factors for Adopting AI-Generated Content Tools
- Sentiment Analysis of Chinese Ancient Poetry Based on Multidimensional Attention Under the Background of Digital Intelligence Integration
Articles in the same Issue
- Frontmatter
- Factors Influencing the Adoption of Green Libraries for Environmental Sustainability: A Systematic Literature Review
- Dimensions of the Ukrainian War in British Press: A Topic Modeling Approach
- Library Leadership in Minority Serving Institutions: Investigating the Backgrounds of MSI Library Directors
- Characteristics of OA Diamond Journal Publishing in Non-English-Speaking Countries
- Aging-Related Information Needs and Barriers Experienced by LGBT+ Older Adults
- Graduate Education in China Meets AI: Key Factors for Adopting AI-Generated Content Tools
- Sentiment Analysis of Chinese Ancient Poetry Based on Multidimensional Attention Under the Background of Digital Intelligence Integration