Technology in School

Helping Students See Hamlet and Harry Potter in a New Light With Computational Thinking

By Shuchi Grover     Nov 28, 2018

Helping Students See Hamlet and Harry Potter in a New Light With Computational Thinking

Like many kids of my generation growing up in India, I was an avid reader of Enid Blyton’s novels. Many of her books were written as a series (“The Famous Five,” “The Secret Seven” and “Five Find-Outers”) and I recall wondering if the lives of characters overlapped in any way. Did a character from one series ever run into one from another, for example? I recall wondering the same thing in later years about P.G. Wodehouse’s Blandings Castle and Jeeves series.

Today, in a world where communities real and imagined are digitally connected via platforms like Facebook, Instagram and Tumblr, we can reframe that question in terms of those common nodes (or friends) in those characters’ social networks.

As it turns out, network theory as an analytic technique, or what I’d call computational literary analysis, is not just a bona fide research endeavor. It’s also a great example of how computational thinking (CT) is truly a cross-disciplinary skill that can be weaved to enrich learning in any subject (not just math and science, as is sometimes the assumption). In an earlier article on computational thinking, I offered teasers of how CT could be integrated into language arts and social studies, in addition to math and science.

Here’s a detailed treatment of one of those examples, drawn from the work of Franco Moretti’s group on “Computational Criticism,” which is part of the broader Digital Humanities initiative at Stanford. (See this New York Times profile for more on the work of this group).

I first became aware of Moretti’s work in a Boston Globe article provocatively titled, “Hamlet and the Region of Death.” It led me to his fascinating “Network Theory Plot Analysis” in which he describes the use of social graphs to analyze Shakespeare’s popular tragedy.

This kind of literary analysis basically involves analyzing “network diagrams” or “interaction graphs,” where characters are represented as nodes and two characters are joined by an edge if they have interacted through dialogue. Such a representation of a novel can facilitate a unique look at stories (even though it loses the temporal dimension). As the article observes:

“Seen through Moretti’s network diagrams, ‘Hamlet’ often seems brand new. One notices, for example, that of all the characters who speak to both Hamlet and Claudius, only two manage to survive the play (Moretti calls this part of the network the “region of death”). The tragedy he wrote is all there in that graph. Or one notices that Rosencrantz and Guildenstern, the most famous pair of minor characters in all of Shakespeare, never speak to each other.”

Moretti’s research paper on this work also describes a network of Hamlet without Hamlet. How absolutely fascinating it is to analyze relationships in a play without the lead character in the picture!

Computational literary analysis of character relationships in Hamlet
Image credit: Shuchi Grover

This technique provides not only a new analytic lens into a literary work, but also helps students experience the value of abstractions or representations such as graphs, and the organization of information into a discrete data structure. If we wanted to take a deeper computer-science approach and make computational thinking connections with this literary activity, students could transform the graph in Figure 1 below to a 2-dimensional data structure, or “adjacency matrix” by marking edges between nodes with a check mark (Figure 2).

Literary computational analysis exercise
Image credit: Shuchi Grover

And if we replaced ✓’s by 1’s (Figure 3 below), the adjacency matrix could then be represented as a 2D array data structure in a program, thus allowing the social graph to then be analyzed computationally. Once students have created this 2D matrix representation of a social graph, a row/column total easily provides the number of connections associated with each character (node).

More importantly, though, they’ve taken a crucial step closer to automating analyses (or even just visualization) of the story. The 1’s could also be replaced by a value as a “weight” to represent the number of interactions. And with that extension, the analyses could be expanded to include a whole new set of questions related to the strength of relationships.

Computational literary analysis example
Image credit: Shuchi Grover

Using an appropriate representation or abstraction for problem-solving is a crucial piece of computational thinking. Just as algorithms written in psuedo-code or flowcharts help learners take the step from problem to program, so too do appropriate data structures. One of the most influential early programming textbooks (by Niklaus Wirth, the creator of the Pascal programming language) underscoring the intertwined nature of algorithms and data structures was famously titled “Algorithms + Data Structures = Programs.” In a similar vein, another computer scientist, David Jones, famously wrote, “Get your data structures correct first, and the rest of the program will write itself.”

And why stop at Shakespeare and Hamlet when you could engage kids in a social network analysis of Harry Potter? What if we wanted to know who amongst Harry Potter’s two closest friends, Ron and Hermione, played the more significant role in the novels? As it turns out, some enthusiasts have coded an elaborate network, called “The Wizarding Network of Harry Potter,” to help answer questions such as these.

Relationship mapping from The Wizarding Network of Harry Potter
Screenshot of a relationship map from “The Wizarding Network of Harry Potter.”

Remember, computational thinking is about formulating approaches to problem solving so that the solutions can potentially be solved by a computer. Even if kids do not code such a network, understanding the types of questions that can be answered through such automated abstractions as “The Wizarding Network of Harry Potter” (or some version of it) is an important and useful aspect of understanding how automating the solution impacts the problem-solving process. This also includes understanding what kinds of data and analyses can be automated (and how), and which cannot.

Socially-conscious students in secondary grades may similarly consider analyzing representation of historically underrepresented groups in popular media. Creating interaction graphs of screenplays of films and analyzing characters and roles based on who they interact with would make for a cool CS or language arts project! (As a matter of fact, in recent years such analyses have actually helped to reveal tokenism in Hollywood when it comes to the roles of women and ethnic minorities in film.)

Creating a network graph abstraction, using it to analyze the relationships between characters in a story, transforming the graph into data structure representation (or vice versa), and asking the kinds of questions that can be answered through such abstract models, are all examples of how computational thinking can be valuable for literary analysis in a language arts classroom. Students can do much of this without coding, although taking that next step to code such an abstraction would make this experience even more powerful. Classes where students have experience with coding in programming languages that support 2D data structures should certainly give computational literary analysis a shot. Such a classroom could also discuss the limitations of manually creating graphs and adjacency matrices for lengthy novels, and how computing and natural language processing can automate that process.

Hopefully these ideas have triggered the imagination of not just language arts teachers, but their peers in the humanities and social sciences as well, who can all apply network theory to analyze a whole host of social and cultural phenomena.

Helping Students See Hamlet and Harry Potter in a New Light With...

Technology in School

Helping Students See Hamlet and Harry Potter in a New Light With Computational Thinking

By Shuchi Grover     Nov 28, 2018

Helping Students See Hamlet and Harry Potter in a New Light With Computational Thinking

Like many kids of my generation growing up in India, I was an avid reader of Enid Blyton’s novels. Many of her books were written as a series (“The Famous Five,” “The Secret Seven” and “Five Find-Outers”) and I recall wondering if the lives of characters overlapped in any way. Did a character from one series ever run into one from another, for example? I recall wondering the same thing in later years about P.G. Wodehouse’s Blandings Castle and Jeeves series.

Today, in a world where communities real and imagined are digitally connected via platforms like Facebook, Instagram and Tumblr, we can reframe that question in terms of those common nodes (or friends) in those characters’ social networks.

As it turns out, network theory as an analytic technique, or what I’d call computational literary analysis, is not just a bona fide research endeavor. It’s also a great example of how computational thinking (CT) is truly a cross-disciplinary skill that can be weaved to enrich learning in any subject (not just math and science, as is sometimes the assumption). In an earlier article on computational thinking, I offered teasers of how CT could be integrated into language arts and social studies, in addition to math and science.

Here’s a detailed treatment of one of those examples, drawn from the work of Franco Moretti’s group on “Computational Criticism,” which is part of the broader Digital Humanities initiative at Stanford. (See this New York Times profile for more on the work of this group).

I first became aware of Moretti’s work in a Boston Globe article provocatively titled, “Hamlet and the Region of Death.” It led me to his fascinating “Network Theory Plot Analysis” in which he describes the use of social graphs to analyze Shakespeare’s popular tragedy.

This kind of literary analysis basically involves analyzing “network diagrams” or “interaction graphs,” where characters are represented as nodes and two characters are joined by an edge if they have interacted through dialogue. Such a representation of a novel can facilitate a unique look at stories (even though it loses the temporal dimension). As the article observes:

“Seen through Moretti’s network diagrams, ‘Hamlet’ often seems brand new. One notices, for example, that of all the characters who speak to both Hamlet and Claudius, only two manage to survive the play (Moretti calls this part of the network the “region of death”). The tragedy he wrote is all there in that graph. Or one notices that Rosencrantz and Guildenstern, the most famous pair of minor characters in all of Shakespeare, never speak to each other.”

Moretti’s research paper on this work also describes a network of Hamlet without Hamlet. How absolutely fascinating it is to analyze relationships in a play without the lead character in the picture!

Computational literary analysis of character relationships in Hamlet
Image credit: Shuchi Grover

This technique provides not only a new analytic lens into a literary work, but also helps students experience the value of abstractions or representations such as graphs, and the organization of information into a discrete data structure. If we wanted to take a deeper computer-science approach and make computational thinking connections with this literary activity, students could transform the graph in Figure 1 below to a 2-dimensional data structure, or “adjacency matrix” by marking edges between nodes with a check mark (Figure 2).

Literary computational analysis exercise
Image credit: Shuchi Grover

And if we replaced ✓’s by 1’s (Figure 3 below), the adjacency matrix could then be represented as a 2D array data structure in a program, thus allowing the social graph to then be analyzed computationally. Once students have created this 2D matrix representation of a social graph, a row/column total easily provides the number of connections associated with each character (node).

More importantly, though, they’ve taken a crucial step closer to automating analyses (or even just visualization) of the story. The 1’s could also be replaced by a value as a “weight” to represent the number of interactions. And with that extension, the analyses could be expanded to include a whole new set of questions related to the strength of relationships.

Computational literary analysis example
Image credit: Shuchi Grover

Using an appropriate representation or abstraction for problem-solving is a crucial piece of computational thinking. Just as algorithms written in psuedo-code or flowcharts help learners take the step from problem to program, so too do appropriate data structures. One of the most influential early programming textbooks (by Niklaus Wirth, the creator of the Pascal programming language) underscoring the intertwined nature of algorithms and data structures was famously titled “Algorithms + Data Structures = Programs.” In a similar vein, another computer scientist, David Jones, famously wrote, “Get your data structures correct first, and the rest of the program will write itself.”

And why stop at Shakespeare and Hamlet when you could engage kids in a social network analysis of Harry Potter? What if we wanted to know who amongst Harry Potter’s two closest friends, Ron and Hermione, played the more significant role in the novels? As it turns out, some enthusiasts have coded an elaborate network, called “The Wizarding Network of Harry Potter,” to help answer questions such as these.

Relationship mapping from The Wizarding Network of Harry Potter
Screenshot of a relationship map from “The Wizarding Network of Harry Potter.”

Remember, computational thinking is about formulating approaches to problem solving so that the solutions can potentially be solved by a computer. Even if kids do not code such a network, understanding the types of questions that can be answered through such automated abstractions as “The Wizarding Network of Harry Potter” (or some version of it) is an important and useful aspect of understanding how automating the solution impacts the problem-solving process. This also includes understanding what kinds of data and analyses can be automated (and how), and which cannot.

Socially-conscious students in secondary grades may similarly consider analyzing representation of historically underrepresented groups in popular media. Creating interaction graphs of screenplays of films and analyzing characters and roles based on who they interact with would make for a cool CS or language arts project! (As a matter of fact, in recent years such analyses have actually helped to reveal tokenism in Hollywood when it comes to the roles of women and ethnic minorities in film.)

Creating a network graph abstraction, using it to analyze the relationships between characters in a story, transforming the graph into data structure representation (or vice versa), and asking the kinds of questions that can be answered through such abstract models, are all examples of how computational thinking can be valuable for literary analysis in a language arts classroom. Students can do much of this without coding, although taking that next step to code such an abstraction would make this experience even more powerful. Classes where students have experience with coding in programming languages that support 2D data structures should certainly give computational literary analysis a shot. Such a classroom could also discuss the limitations of manually creating graphs and adjacency matrices for lengthy novels, and how computing and natural language processing can automate that process.

Hopefully these ideas have triggered the imagination of not just language arts teachers, but their peers in the humanities and social sciences as well, who can all apply network theory to analyze a whole host of social and cultural phenomena.

Get our email newsletterSign me up
Keep up to date with our email newsletterSign me up