The emergence of digital humanities echoes the paradigm transformation of literary research. In this project, natural language processing technology is applied to the analysis of ancient Chinese literature, and the attention mechanism is embedded in iterative null convolutional network to build a named entity recognition model based on ancient literature. Then we integrate MacBERT pre-training model, combine the dual-channel structure of aspectual word features and semantic features, design hierarchical attention mechanism, and complete the construction of aspectual-level sentiment analysis model. Through experiments to analyze the model performance and conduct the analysis of ancient literary works, the results can be obtained that the two models show better named entity recognition and sentiment analysis effects, and the values of each evaluation index are above 83%. Craftsmen (44.7%) and merchants (22.4%) appear more frequently in the sample Ming Dynasty fictional characters, revealing the social and cultural background of the development of the commercial economy and the emergence of the civic class at that time. Positive emotions accounted for 67.9% of the poetry samples of the Tang Dynasty, and the war of the country’s reward (0.334) and send-off feelings (0.226) co-occurred most frequently with positive emotions, reflecting the social and cultural background of the Tang Dynasty, which was characterized by prosperity and affluence, and the emergence of the literati to build up their careers.