Currently, Sentiment Analysis (SA) has been gradually applied in a variety of fields and has become one of the most researched topics in adolescent education. However, since the interaction between cognition and emotion is involved in every learning process, it is possible to intervene with students based on the emotions they express in classroom or extracurricular environments, in order to assist teachers in assessing the overall state of students. This is conducive to improving teaching effectiveness, facilitating personalized learning, improving the emotional state and mental health of students, and promoting development and progress in the field of education. Emotion recognition is usually studied using electroencephalography (EEG), which is not practical for the adolescent population that spends most of their time at school almost every day. Therefore, in this paper, we propose an SA method based on a modified transformer network combined with convolutional neural network (CNN), aiming to utilize language for emotion recognition. The experiments were conducted using the Standford Sentinent Treebank (SST) dataset for training and validation of the model, which categorizes emotions into two categories based on positive and negative emotions, and ultimately obtains an overall accuracy of 95.00%. The experimental results demonstrate the recognition ability of our proposed model in sentiment analysis and show the potential for application in adolescent education.