For my project, I decided to make a network visualizing the relationships between six prominent characters in Shakespeare’s A Midsummer Night’s Dream. The aims of this project were to find a correlation between speakers and mentions of other characters and gain experience with XPath filtering, as well as visualize certain dialogues between speakers. The methods and tools used to capture the data were fairly simple: Voyant Tools and Gephi. Gephi is a free and open-source graph network visualization tool that uses nodes and directional edge weight data. I ended up with a graph of how frequently correlated speakers mention each other throughout the book.
I passed a clean XML script of the play into Voyant Tools, and then used the commands SPEECH
and contains
to filter out first the speakers of the play, listing the order in which the characters spoke with this line of XPath: //SPEECH/SPEAKER
. I then used the Trends feature to find when characters were in a particular dialogue.
Finding these correlations, I then filtered out all the lines where a certain character mentioned another in a dialogue with this line (Lysander and Hermia as an example): //SPEECH[SPEAKER='LYSANDER']/LINE[contains(text(), "Hermia)]
Next, I counted the frequency of the character’s name, in this case, Hermia, in the filtered text.
The final step of this project was to visualize the relationships between each character’s mentions, so I turned to Gephi and added nodes for the characters and edges for the frequency of mentions. Here’s what I got:

The lines are curved because they are directional, and directionality follows the edge clockwise. For example, Hermia mentions Lysander 22 times whereas Lysander mentions Hermia 12 times. Quince and Bottom are not connected to the main loop because XPath crashed Voyant when I tried to load it with filter settings that mention them with characters from the main loop.
This frequency graph gives a better idea of the relationships between characters during a dialogue and could provide more insights into their relationship beyond just mentions. The XPath filtering line was very useful to obtain the order of speakers and frequency of mentions of other characters. Some pitfalls of the approach include the inaccuracy of Voyant and XPath filters. When Voyant crashed the import of the corpus using Bottom mentioning Lysander as the filter, I realized that the message was very vague and didn’t tell me that Bottom did not mention Lysander. The filter failed because Bottom did not mention Lysander, but the error was vague and did not tell me that. Another pitfall is that I could not find a third-party resource that could reliably display an interactive directional graph, so I had to use a PNG instead of a full embed of the SVG that I exported.
You can find the full embed and link to Voyant on my individual website with some tips and tricks for filtering. I was able to post a WordPress blog with the results and an XPath cheat sheet.