The same series of posts:
Python Simple Combat Project: "Ice and Fire song 1-5" Role relationship map construction
Python Simple Combat Project: "Song of Ice and Fire 1-5" construction of role relationship map--Database design
Scrapy+redis+mongodb distributed crawler crawl novel "Ice and Fire song 1-5"
Let's get a gephi to draw a cool figure diagram.
Each node in the diagram represents a role, the connection between the node and the node is shared, and the thickness of the line indicates how often the frequency is. The size of the node and the size of the color depth representation, i.e. the total frequency at which a role participates in the present.
Now let's talk about the implementation steps of this diagram:
1. Role extraction of the extracted corpus
2. Merging of roles with the same chapter
3. Use the data in step 2 for the matrix calculation
4. Use Ucinet, Netdraw, Gephi to realize the visualization of the co-present matrix. 1. Role extraction of the extracted corpus
Previously used is the Jieba and Nlpir two natural language processing packages for role extraction, but later found that the effect is particularly poor, all the back from the Baidu Encyclopedia on a number of role list down, that this and the original text for comparison, to achieve the role of extraction.
2. Merging of roles with the same chapter
When you are writing a reptile, you can pull the characters while you crawl.
3. Use the data in step 2 for the matrix calculation
Read the database and use the keyword-sharing matrix algorithm to build the matrix.
Algorithm please refer to Python building keyword co-present matrix
Co-present Matrix 4. Using Ucinet, Netdraw, Gephi to realize visualization of the co-present matrix
The focus of this blog is here ~
Click to open Ucinet,
Click file→open→ to select the matrix data in CSV format
After the data is successfully imported, then click File→save as to save the data as. # #h后缀格式文件.
Open the Netdraw, and click on the following figure to open the just saved. # #h文件
This time actually can be found, Netdraw has been the total network has been mapped out, but the effect is too low, so here use Gephi to draw better results.
Before using Gephi, you need to save the Netdraw open file as a. net file.
Open the run Gephi and use Gephi to open the. NET suffix file that you just saved.
Because it is a simple abstraction of a character, there is no directional transfer between roles and roles, so there is no direction to choose from.
If it is Chinese text, the font below also needs to be changed to Chinese font. such as bold, XXFarEastFont-Arial.
The function of filtering is to filter the result, and set the degree to be the filter condition.