For Automatic Generation of Character Maps Using NLP
This package (in progress) can be used to analyze a .mobi
ebook and determine the relationships between characters. Below is a sample graph generated from analysis of Harry Potter and the Philosopher's Stone by J.K. Rowling.
There are two inputs that are used the script. These are the ebook in .mobi
format and a text list of the characters that you want to analyze where each character is separated by a newline character. These scripts will read through the ebook file and find instances in which different characters interact. This is tabulated as probabilities of characters co-appearing. After probabilities are generated, a graph depicting significant relationships is rendered.
from gnovel.main import Gnovel
novel_graph = Gnovel('book.mobi', 'character_list.txt')
novel_graph.draw_graph('output.file')
Make sure that your python environment has the following dependencies installed:
BeautifulSoup
nltk
tqdm
numpy
pandas
matplotlib
networkx
- Character recognition using named-entity recognition (NER)
- Relationship positivity (Sentiment Analysis)