Comparing the Quran, Tanakh & Bible using NLP and IBM Sentiment Analysis

Christopher Cinq-Mars Jarvis
Cinq-Mars Media
Published in
4 min readJun 7, 2017

--

In three years I’ve posted only a handful of times on Facebook. I prefer to sit back and watch as my ménage of diverse ‘friends’ scream down each other’s politics with caps lock turned on— it makes for occasionally entertaining, albeit depressing theatre. A recent exchange in particular caught my eye on the relationship between the Quran and Islamic terror — a standby these days whenever there is an act of terrorism abroad. It occured to me that Machine Learning, Natural Language Processing and Sentiment Analysis could contribute to such a conversation.

I’ve recently been dabbling in Machine Learning at Kaggle, a site I can‘t recommend highly enough. My last competition there involved Natural Language Processing and sentiment analysis — tools I’ve been playing around with for a new game with IBM Cloud Tone Analyzer. Comparing modern translations of religious texts using these tools seemed like an interesting aside, and the Tone Analyzer service seemed like a robust method to do it.

Results for the first two pages of Genesis from the King James Bible

Using the demo here, you get the gist of how it works — think of it as NLTK sentiment analysis backed by IBM Watson Machine Learning. A major hurdle is it’s 50kb limit, which meant I had to break the sanitized texts into thousands of chunks and analyze them separately. Combining them, these were the results:

I was shocked the Quran performed as well as it did, so much so that I went back to double check it. Having read all three texts, I expected they would all be quite similar (which they are), and perhaps even that the Tanakh would edge out the others in anger and sadness, but I certainly did not anticipate the Quran having such an advantage in the conscientiousness metric. This metric was the only one that was statistically significant, as all three texts performed quite similarly in most cases — but if it were a competition, the Quran certainly ‘won’.

Quran: Most relevant metrics over the course of the text (x-axis) expressiveness (y-axis)

While the Quran was lowest in expressions of anger, disgust, fear and highest in joy, agreeableness and conscientiousness, these results are far from conclusive. The length of the Quran (much shorter) may have been an asset to it (as you can see the above results are remarkably consistent, likely thanks in part to the shorter text), the Itani translation might be particularly gentle, omission of the old testament or direct Arabic analysis might have yielded a more favorable comparison, etc… I should note, too, that the Quran had the highest standard deviation on these metrics, (though this in part could be attributed to its relatively short length).

King James Bible: Most relevant metrics over the course of the text (x-axis) expressiveness (y-axis)

This graph, a breakdown of our metrics over the course of the Bible (starting with the Genesis and ending with Revelation), is startlingly inconsistent compared to the Quran. This might be due to several factors, perhaps longer length, heavier abstraction (more analogy and metaphor), a more episodic and compartmentalized structure, etc… Also surprising is how the Old Testament doesn’t seem to express more anger or disgust than the New Testament, though it does register as less joyous.

Tanakh (Hebrew Bible): Most relevant metrics over the course of the text (x-axis) expressiveness (y-axis)

I will not pretend as though these findings were anything more than the results of a fun little experiment done by an NLP novice. I am by no means qualified in this disclipline to make any claims about the intrinsic nature of these texts, but one would think if the Quran was significantly more hateful and violent, there would at least be some evidence of that in the above results.

I find the idea of NLP and sentiment analysis on religious texts highly compelling, and in sharing this I hope someone far more talented in these realms than I is inspired to do a more comprehensive and accurate inquiry. Building a custom grammar to detect violence advocacy, considering more translations, and even breaking down results in the original Hebrew or Arabic would be fascinating. I looked into doing this with a friend, but the only resource I was able to find, Stanford Arabic Parser, seemed incomplete and too modernized.

--

--

Filmmaker and Game/Software Developer. Creator of Synonymy, PhoneFlare, PolitiTruth. Showcased at E3, GDC, NYFF, Telluride, Student Academy Awards, Mobileys.