Journal of Computer Applications ›› 2025, Vol. 45 ›› Issue (6): 1827-1832.DOI: 10.11772/j.issn.1001-9081.2024060885
• Artificial intelligence • Previous Articles
					
						                                                                                                                                                                                                                    Jian SHUAI, Zhongqing WANG( ), Jiali CHEN
), Jiali CHEN
												  
						
						
						
					
				
Received:2024-07-08
															
							
																	Revised:2024-10-17
															
							
																	Accepted:2024-10-22
															
							
							
																	Online:2024-10-30
															
							
																	Published:2025-06-10
															
							
						Contact:
								Zhongqing WANG   
													About author:SHUAI Jian, born in 2001, M. S. candidate. His research interests include natural language processing, aspect-based sentiment analysis.Supported by:通讯作者:
					王中卿
							作者简介:帅健(2001—),男,江西南昌人,硕士研究生,主要研究方向:自然语言处理、细粒度情感分析基金资助:CLC Number:
Jian SHUAI, Zhongqing WANG, Jiali CHEN. Aspect-based sentiment analysis method based on code generation[J]. Journal of Computer Applications, 2025, 45(6): 1827-1832.
帅健, 王中卿, 陈嘉沥. 基于代码生成的细粒度情感分析方法[J]. 《计算机应用》唯一官方网站, 2025, 45(6): 1827-1832.
Add to citation manager EndNote|Ris|BibTeX
URL: https://www.joca.cn/EN/10.11772/j.issn.1001-9081.2024060885
| 自然语言 | PL | 
|---|---|
| 基类 | class Root() | 
| 四元组派生类 | class Quad(Root) | 
| 成员函数1 | def Func1() | 
| 成员函数2 | def Func2() | 
| 成员函数参数 | aspect/category/opinion/sentiment | 
Tab.1 Mapping relationship between quadruples and PL
| 自然语言 | PL | 
|---|---|
| 基类 | class Root() | 
| 四元组派生类 | class Quad(Root) | 
| 成员函数1 | def Func1() | 
| 成员函数2 | def Func2() | 
| 成员函数参数 | aspect/category/opinion/sentiment | 
| 超参数 | 值 | 
|---|---|
| 批大小 | 8 | 
| 学习率 | 3×10-4 | 
| 权重衰减 | 10-3 | 
| 训练轮数 | 10 | 
| 损失函数 | 交叉熵 | 
Tab.2 Hyperparameters setting
| 超参数 | 值 | 
|---|---|
| 批大小 | 8 | 
| 学习率 | 3×10-4 | 
| 权重衰减 | 10-3 | 
| 训练轮数 | 10 | 
| 损失函数 | 交叉熵 | 
| LoRA参数 | 值 | 
|---|---|
| lora_r | 8 | 
| lora_alpha | 16 | 
| lora dropout | 0.05 | 
| lora_target_modules | q_proj, v_proj k_proj, o_proj down_proj, up_proj | 
Tab.3 LoRA parameters setting
| LoRA参数 | 值 | 
|---|---|
| lora_r | 8 | 
| lora_alpha | 16 | 
| lora dropout | 0.05 | 
| lora_target_modules | q_proj, v_proj k_proj, o_proj down_proj, up_proj | 
| 模型/方法 | 餐厅 | 笔记本 | ||||
|---|---|---|---|---|---|---|
| P | R | F1 | P | R | F1 | |
| T5 | 0.554 1 | 0.497 2 | 0.524 2 | 0.402 6 | 0.386 4 | 0.394 4 | 
| CodeBERT | 0.395 3 | 0.429 6 | 0.411 7 | 0.326 1 | 0.285 4 | 0.304 3 | 
| CodeT5 | 0.421 6 | 0.479 3 | 0.448 6 | 0.371 4 | 0.304 8 | 0.334 8 | 
| CodeT5+ | 0.446 4 | 0.481 1 | 0.463 1 | 0.382 9 | 0.315 8 | 0.346 1 | 
| InCoder | 0.362 8 | 0.413 7 | 0.386 5 | 0.319 6 | 0.292 5 | 0.305 4 | 
| Llama2 | 0.595 0 | 0.580 7 | 0.587 8 | 0.428 5 | 0.373 4 | 0.399 1 | 
| Paraphrase | 0.589 8 | 0.591 1 | 0.590 4 | 0.417 7 | 0.450 4 | 0.433 4 | 
| Seq2Path | 0.602 9 | 0.596 1 | 0.599 5 | 0.437 5 | ||
| OTG | 0.440 8 | 0.439 4 | ||||
| 本文方法 | 0.649 6 | 0.639 7 | 0.644 6 | 0.444 6 | 0.435 8 | 0.440 2 | 
Tab.4 Comparison of proposed model and baseline models and methods
| 模型/方法 | 餐厅 | 笔记本 | ||||
|---|---|---|---|---|---|---|
| P | R | F1 | P | R | F1 | |
| T5 | 0.554 1 | 0.497 2 | 0.524 2 | 0.402 6 | 0.386 4 | 0.394 4 | 
| CodeBERT | 0.395 3 | 0.429 6 | 0.411 7 | 0.326 1 | 0.285 4 | 0.304 3 | 
| CodeT5 | 0.421 6 | 0.479 3 | 0.448 6 | 0.371 4 | 0.304 8 | 0.334 8 | 
| CodeT5+ | 0.446 4 | 0.481 1 | 0.463 1 | 0.382 9 | 0.315 8 | 0.346 1 | 
| InCoder | 0.362 8 | 0.413 7 | 0.386 5 | 0.319 6 | 0.292 5 | 0.305 4 | 
| Llama2 | 0.595 0 | 0.580 7 | 0.587 8 | 0.428 5 | 0.373 4 | 0.399 1 | 
| Paraphrase | 0.589 8 | 0.591 1 | 0.590 4 | 0.417 7 | 0.450 4 | 0.433 4 | 
| Seq2Path | 0.602 9 | 0.596 1 | 0.599 5 | 0.437 5 | ||
| OTG | 0.440 8 | 0.439 4 | ||||
| 本文方法 | 0.649 6 | 0.639 7 | 0.644 6 | 0.444 6 | 0.435 8 | 0.440 2 | 
| 样式 | 餐厅 | 笔记本 | ||||
|---|---|---|---|---|---|---|
| P | R | F1 | P | R | F1 | |
| 代码样 | 0.635 4 | 0.614 6 | 0.624 8 | 0.434 8 | 0.425 4 | 0.430 1 | 
| 代码样 | 0.649 6 | 0.649 6 | 0.649 6 | 0.444 6 | 0.435 8 | 0.440 2 | 
Tab.5 Comparison of results for different code patterns
| 样式 | 餐厅 | 笔记本 | ||||
|---|---|---|---|---|---|---|
| P | R | F1 | P | R | F1 | |
| 代码样 | 0.635 4 | 0.614 6 | 0.624 8 | 0.434 8 | 0.425 4 | 0.430 1 | 
| 代码样 | 0.649 6 | 0.649 6 | 0.649 6 | 0.444 6 | 0.435 8 | 0.440 2 | 
| 1 | QIU G, LIU B, BU J, et al. Opinion word expansion and target extraction through double propagation[J]. Computational Linguistics, 2011, 37(1): 9-27. | 
| 2 | TANG D, QIN B, FENG X, et al. Effective LSTMs for target-dependent sentiment classification[C]// Proceedings of the 26th International Conference on Computational Linguistics: Technical Papers. [S.l.]: The COLING 2016 Organizing Committee, 2016: 3298-3307. | 
| 3 | PENG H, XU L, BING L, et al. Knowing what, how and why: a near complete solution for aspect-based sentiment analysis[C]// Proceedings of the 34th AAAI Conference on Artificial Intelligence. Palo Alto: AAAI Press, 2020: 8600-8607. | 
| 4 | CAI H, XIA R, YU J. Aspect-category-opinion-sentiment quadruple extraction with implicit aspects and opinions[C]// Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers). Stroudsburg: ACL, 2021: 340-350. | 
| 5 | ZHANG W, LI X, DENG Y, et al. Towards generative aspect-based sentiment analysis[C]// Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 2: Short Papers). Stroudsburg: ACL, 2021: 504-510. | 
| 6 | YAN H, DAI J, JI T, et al. A unified generative framework for aspect-based sentiment analysis[C]// Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers). Stroudsburg: ACL, 2021: 2416-2429. | 
| 7 | ZHANG W, DENG Y, LI X, et al. Aspect sentiment quad prediction as paraphrase generation[C]// Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2021: 9209-9219. | 
| 8 | BAO X, WANG Z, JIANG X, et al. Aspect-based sentiment analysis with opinion tree generation[C]// Proceedings of the 31st International Joint Conference on Artificial Intelligence. California: ijcai.org, 2022: 4044-4050. | 
| 9 | BU J, REN L, ZHENG S, et al. ASAP: a Chinese review dataset towards aspect category sentiment analysis and rating prediction[C]// Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. Stroudsburg: ACL, 2021: 2069-2079. | 
| 10 | XU L, LI H, LU W, et al. Position-aware tagging for aspect sentiment triplet extraction[C]// Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2020: 2339-2349. | 
| 11 | ZHANG M, QIAN T. Convolution over hierarchical syntactic and lexical graphs for aspect level sentiment analysis [C]// Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2020: 3540-3549. | 
| 12 | CAI H, TU Y, ZHOU X, et al. Aspect-category based sentiment analysis with hierarchical graph convolutional network[C]// Proceedings of the 28th International Conference on Computational Linguistics. [S.l.]: International Committee on Computational Linguistics, 2020: 833-843. | 
| 13 | 李自亮,朱广丽,张玉雷,等. 集成句法与情感知识的方面级情感分析模型[J/OL]. 计算机应用 [2024-09-01].. | 
| LI Z L, ZHU G L, ZHANG Y L, et al. Aspect-based sentiment analysis model integrating syntax and sentiment knowledge[J/OL]. Journal of Computer Applications [2024-09-01].. | |
| 14 | MADAAN A, ZHOU S, ALON U, et al. Language models of code are few-shot commonsense learners[C]// Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2022: 1384-1403. | 
| 15 | GAO L, MADAAN A, ZHOU S, et al. PAL: program-aided language models[C]// Proceedings of the 40th International Conference on Machine Learning. New York: JMLR.org, 2023: 10764-10799. | 
| 16 | WANG X, LI S, JI H. Code4Struct: code generation for few-shot event structure prediction[C]// Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Stroudsburg: ACL, 2023: 3640-3663. | 
| 17 | LI Q, JI H, HUANG L. Joint event extraction via structured prediction with global features[C]// Proceedings of the 51st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Stroudsburg: ACL, 2013: 73-82. | 
| 18 | LIU J, CHEN Y, LIU K, et al. Event extraction as machine reading comprehension[C]// Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2020: 1641-1651. | 
| 19 | LI S, JI H, HAN J. Document-level event argument extraction by conditional generation[C]// Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. Stroudsburg: ACL, 2021: 894-908. | 
| 20 | LU Y, LIN H, XU J, et al. Text2Event: controllable sequence-to-structure generation for end-to-end event extraction[C]// Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers). Stroudsburg: ACL, 2021: 2795-2806. | 
| 21 | VASWANI A, SHAZEER N, PARMAR N, et al. Attention is all you need [C]// Proceedings of the 31st International Conference on Neural Information Processing Systems. Red Hook: Curran Associates Inc., 2017: 6000-6010 . | 
| 22 | TOUVRON H, MARTIN L, STONE K, et al. Llama 2: open foundation and fine-tuned chat models[EB/OL]. [2024-04-21].. | 
| 23 | RAFFEL C, SHAZEER N, ROBERTS A, et al. Exploring the limits of transfer learning with a unified text-to-text transformer[J]. Journal of Machine Learning Research, 2020, 21: 1-67. | 
| 24 | FENG Z, GUO D, TANG D, et al. CodeBERT: a pre-trained model for programming and natural languages [C]// Findings of the Association for Computational Linguistics: EMNLP 2020. Stroudsburg: ACL, 2020: 1536-1547. | 
| 25 | WANG Y, WANG W, JOTY S, et al. CodeT5: identifier-aware unified pre-trained encoder-decoder models for code understanding and generation[C]// Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2021: 8696-8708. | 
| 26 | WANG Y, LE H, GOTMARE A, et al. CodeT5+: open code large language models for code understanding and generation[C]// Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2023: 1069-1088. | 
| 27 | FRIED D, AGHAJANYAN A, LIN J, et al. InCoder: a generative model for code infilling and synthesis [EB/OL]. [2024-04-21].. | 
| 28 | ZHANG W, DENG Y, LI X, et al. Aspect sentiment quad prediction as paraphrase generation [C]// Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing. Stroudsburg: ACL, 2021: 9209-9219. | 
| 29 | MAO Y, SHEN Y, YANG J, et al. Seq2path: generating sentiment tuples as paths of a tree [C]// Findings of the Association for Computational Linguistics: ACL 2022. Stroudsburg: ACL, 2022: 2215-2225. | 
| [1] | Ziliang LI, Guangli ZHU, Yulei ZHANG, Jiajia LIU, Yixuan JIAO, Shunxiang ZHANG. Aspect-based sentiment analysis model integrating syntax and sentiment knowledge [J]. Journal of Computer Applications, 2025, 45(6): 1724-1731. | 
| [2] | Peng CAO, Guangqi WEN, Jinzhu YANG, Gang CHEN, Xinyi LIU, Xuechun JI. Efficient fine-tuning method of large language models for test case generation [J]. Journal of Computer Applications, 2025, 45(3): 725-731. | 
| [3] | Shuo SUN, Wei ZHANG, Wendi FENG, Yuwei ZHANG. Automatic foreign function interface generation method based on source code analysis [J]. Journal of Computer Applications, 2024, 44(7): 2151-2159. | 
| [4] | Zhixiong ZHENG, Jianhua LIU, Shuihua SUN, Ge XU, Honghui LIN. Aspect-based sentiment analysis model fused with multi-window local information [J]. Journal of Computer Applications, 2023, 43(6): 1796-1802. | 
| [5] | LIU Huan, DOU Quansheng. Aspect-based sentiment analysis model embedding different neighborhood representations [J]. Journal of Computer Applications, 2023, 43(1): 37-44. | 
| [6] | LIU Hui, MA Xiang, ZHANG Linyu, HE Rujin. Aspect-based sentiment analysis model integrating match-LSTM network and grammatical distance [J]. Journal of Computer Applications, 2023, 43(1): 45-50. | 
| [7] | GUO Zhipeng, LIU Jinglei. Optimal coalition structure generation in monotonous overlapping coalition [J]. Journal of Computer Applications, 2021, 41(1): 103-111. | 
| [8] | JIANG Jianchun, CHEN Huiling, DENG Lu, ZHAO Jianpeng. Configuration tool design based on control-oriented multi-core real-time operating system [J]. Journal of Computer Applications, 2016, 36(3): 765-769. | 
| [9] | HU Zhengyu, SHEN Beijun. End-user programming language for mobile children educational game [J]. Journal of Computer Applications, 2015, 35(2): 540-544. | 
| [10] | Kui CAI Lei LU Shuai-qiang WANG Jian-cheng WAN. Complicated behaviors modeling and code generation based on Web UI design pattern [J]. Journal of Computer Applications, 2009, 29(4): 1139-1142. | 
| [11] | . An automatic generation algorithm of MPI communication code [J]. Journal of Computer Applications, 2007, 27(3): 759-761. | 
| Viewed | ||||||
| Full text |  | |||||
| Abstract |  | |||||