Skip to content

A Flask app that processes text of a book and outputs visualizations based on characters.

License

MIT, MIT licenses found

Licenses found

MIT
license
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

mitramir55/Character-Network-Flask

Repository files navigation

Analyze your favourit Book!

This webapp is created to tell you what characters decide for the plot, who is the dominant one, and how they interact with each other. From November 2022, the website - Link - can only be run locally since the host shut down its free servers and this app is too big for other free servers.

How to use: clone the project, install Flask, and enter flask run in your terminal.

preview of the website

A preview

We'll go through every step to give you an idea of what this app does.

Book Info

First, you enter the book details (name and the way chapters are in the text). With the help of this info, the website scrapes more info from GoodReads website to tell you about the author, year of publishing, and other facts. The SpaCy small model is also utilized in this step to count the number of sentences in the file you upload.

image

Sentiment Analysis

We separate sentences with SpaCy and analyze them with Afinn. At the end we get a nice graph of the overall mood of the book.

pic2_senti

Named Entity Recognition - NER

After saving the sentiment indicator for each sentence, we once again process them and look for names of people\characters in the book.

pic3_ner1

Sometimes, you might not see the names of specific characters or just find some redundant names between them. If there was any change you wanted to make in the list, you can simply use the last two boxes to write the names of people in.

pic4_ner2

Co-occurrence

For this part, we analyze at how characters interact with each other by looking at their mutual occurrence in one sentence. Then, we use the sentiment scores of these sentences and create a table indicating characters relationships.

pic5_co1

Character Progress

Because we want to get a good overview of characters' roles and importance, we also look at their presence through out the book. We do that by segmenting text into n pieces and counting the appearance of each person in that segment.

pic6_progress

The Graph

The final step is creating a graph. For this visualization, I utilized D3 library Graph force to depict nodes and edges.

pic7_graph

How to contribute?

If you're interested, you can either add features to this project or fork it to create your own. The license of this project is MIT license.

Resources: