Jun 01, 2021 Article blog
This article was reproduced to Know ID: Charles (Bai Lu) knows his personal column
Download the W3Cschool Mobile App, 0 Foundation Anytime, Anywhere Learning Programming >> Poke this to learn
Use Python's simple products to read/analyze novels
T_T is purely entertainment
If there is a thunderbolt, not very honored to
Let's Go~~~
Don't want to see the process please pull down directly to the end to see the results
Web disk download link:
https://pan.baidu.com/s/1D5dITcY27S0ji8nyJUP2fA
Password: c3kd
Python version: 3.6.4
Related modules:
gensim module;
Jieba module;
scipy module;
snownlp module;
matplotlib module;
numpy module.
Install Python and add it to the environment variable, and pip installs the relevant modules that are required.
Additional instructions:
Pip download speed is too slow:
Temporary/permanent source change to s (Baidu has a lot of tutorials T_T)
Pip installation failed:
Download the whl file installation to a website like https://www.lfd.uci.edu/~gohlke/pythonlibs/.
(1) Analysis of the main characters of the novel
Count the number of times each character appears in the novel, and assume that the more times it appears, the higher the character's position in the novel.
(2) Analysis of the relationship between the characters in the novel
Use gensim to generate a word vector model to analyze relationships.
T_T this model is Google in 2013 open source out, the specific implementation details have not yet come to see, not deep learning, but shallow neural networks
(3) Emotional analysis of novels
The snownlp library is mainly utilized.
The implementation process can be found in the source code.
Additional notes
Before analyzing a novel, you need to go to the relevant website to download the text file of the novel and create a new text file containing the names of all the characters in the novel.
To modify the source code (analysis.py):
if __name__ s '__main__' :(98 lines)
After the novel file path below, run in the cmd window.
T_T first let's take a look at this book I've read for 20 years and only read the first three pages of the first three pages of the chinese classical four masterpieces!!!
Top 10:
The first few names are still familiar???
People diagram:
Also do not know reliable no, clustering to get the picture of the
T_T came to this conclusion at will (escape):
The emotional tone of the novel as a whole (negative or positive?)
):
Take 0.5 as the boundary, the left represents the negative, the right represents the positive
It's so extreme T_T
T_T've only seen TV dramas
Top 10:
There may be some places is Joe Feng, some places are the reason for Xiao Feng, after all, I think Qiao Feng is the main character ah!
People diagram:
and the conclusions that come with it:
T_T destroy three views ah
The emotional tone of the novel as a whole (negative or positive?) ):
Excuse me???
Don't play T_T
The above contents are purely unprofessional and unscientific pure entertainment analysis
Interested in analyzing other novels T_T
Perhaps we can get a shocking conclusion