Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Python reads novels simply


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

Lead

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


Related documents

Web disk download link: https://pan.baidu.com/s/1D5dITcY27S0ji8nyJUP2fA

Password: c3kd


Develop tools

Python version: 3.6.4

Related modules:

gensim module;

Jieba module;

scipy module;

snownlp module;

matplotlib module;

numpy module.


Environment construction

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/.


The main idea

(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.


Python Magenta House

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:

 Python reads novels simply1

The first few names are still familiar???

People diagram:

 Python reads novels simply2

Also do not know reliable no, clustering to get the picture of the

T_T came to this conclusion at will (escape):

 Python reads novels simply3

The emotional tone of the novel as a whole (negative or positive?) ):

 Python reads novels simply4

Take 0.5 as the boundary, the left represents the negative, the right represents the positive

It's so extreme T_T


Python Pin tianlong eight

T_T've only seen TV dramas

Top 10:

 Python reads novels simply5

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:

 Python reads novels simply6

and the conclusions that come with it:

 Python reads novels simply7

T_T destroy three views ah

The emotional tone of the novel as a whole (negative or positive?) ):

 Python reads novels simply8

Excuse me???


more

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