Journey to Middle Earth - Webscraping the Lord of the Rings

Posted on Jan 9, 2018

The Lord of the Rings is an epic high fantasy novel written by English author and scholar J. R. R. Tolkien. It built Middle Earth, a multi-race inhabited world as setting of whole story. In this project, I will mainly focus on finding funny facts of middle earth and analyzing movie script of Lord of the Rings trilogy.

 

Webscraping


Since there was no related dataset, I should start from scraping data online. I found two website:

lotr.wikia - which included demography information for Middle Earth

ageofthering.com - which included movie script of  the Lord of the Rings

For the demography website, I scraped name, birth and death year, gender, race, spouse, hair, height, realm, etc. of a thousand characters in Middle Earth. For the movie script website, I scraped all the lines of three Lord of the Rings movies along with name of movies and name of characters that line belongs to, which gave me another 2400 rows dataset.

 

Demography in Middle Earth


The first plot shows the race and gender distribution among those 1000 characters. Obviously that men are the majority race in the whole story and most of the characters described in the book is male. To be noticed that there is only one female dwarf in whole story and no female orc at all.

The second plot shows the average life span for different race. As shown, Maiar has extremely long lifespan (seems won’t die unless unnatural causes). After did more research on that race, I found that many important characters such as Gandalf, Saruman and Sauron were all belong to that race and lived for more than 7000 years already.

The third plot shows the count of inhabitants of different race by year in Middle Earth. Population of elves seems pretty stable before fourth age because its long lifespan. As Lord of the Rings trilogy happened, the population structure dramatically changed.

Notice that the data only includes characters have been written in the book, the result above does not represent whole population of Middle Earth.

 

The plots above show the marital status in Middle Earth. Reasonably, Hobbits have the highest marriage rate among all races. Although only one female dwarf mentioned in the book, there are still 36% dwarves married, most of them are supposed to marry unmentioned female dwarves. Orcs never married. Additionally, there are no homosexual marriage in the whole story and only one character has remarriage.

 

Movie Script


The chart above shows number of sentences spoken by different characters in different movies.

The word cloud shows frequency of words spoken by different characters. The most frequent word spoken by Frodo and Sam is each other’s name. Comparing Gandalf and Aragorn, it’s easy to find that the most frequent words spoken by such heroic character is “Will”. Although sharing same body, Gollum and Sméagol have totally different personalities, and the words cloud well represent the difference.

 

Sentimental Analysis 


The bubble chart above shows the result of sentimental analysis on sentences spoken by different characters. Not surprisingly, Merry and Pippin, those two happy hobbits get the highest positive score. But unexpectedly, Sam has the highest negative score. It might because he is the person who gives Frodo exhortation, tells him what shouldn’t do, who shouldn’t trust and always considers danger, which makes his words sounds more negative.


Thanks for browsing my work! If you have any question or suggestion, please feel free to contact me via my email : [email protected]

About Author

Tianyi Gu

Tianyi Gu is a creative thinker with strong quantitative and analytical skills. Tianyi received his MS in Urban Informatics from New York University and BS in Actuarial Science from SUNY Buffalo. With great passion in infinite possibilities in...
View all posts by Tianyi Gu >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI