eMFD and More Hearts

A survey of Jonathan Haidt's Moral Foundation Theory and popular music.

By Monty Reynolds

January 25, 2021

Once again, the purpose of this post is primarily for my own recollection. Here I will be using Hopp et al. (2021) extended moral foundations dictionary1 on the song More Hearts than Mine by Ingrid Andress. I’ve done other forms of sentiment analysis on this song in the past and I have never been too comfortable with the results. I think that this ought to be expected seeing as how this song does a great job in exploring the conflicting emotions someone might have in introducing a romantic interest to other relationships that one has a more extensive history with.

First, following the very clear tutorial that the github page for the excellent tutorial that is provided,2 we import the following python packages which includes pandas, numpy, seaborn, the style package “whitegrid”, and the plot library “matplotlib”. If you do not already have any of these packages installed, you should do so: pip install PACKAGE. We then set our fonts, style and import the documents that we will initially emfd on. Finally, we import our first set of documents. These consist of a number of news articles provided if you decided to clone the github repository linked to above.

import pandas as pd
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt

template_input = pd.read_csv("/home/redapemusic35/1-2021-22-Projects/Publications/Research-Projects/eMFD/emfdscore/emfdscore/template_input.csv", header=None)

Our initial document file is displayed below. It consists of a number of news articles in a csv file with one document per row.


articles <- read.csv("~/1-2021-22-Projects/Publications/Research-Projects/eMFD/emfdscore/emfdscore/template_input.csv")

##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       The.Iraqi.government.s.assault.to.retake.the.city.of.Mosul.could.take.months..prompting.more.and.more.civilians.to.try.to.flee.to.avoid.being.trapped.between.frontlines..a.senior.official.of.the.International.Committee.of.the.Red.Cross.told.Reuters.. ...
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 WASHINGTON -- North Korea now has the capability to launch a nuclear weapon, a senior U.S. military official said Thursday, adding that while the U.S. believes Pyongyang can mount a warhead on a missile, it’s not clear that it can hit a target.\n\nThe official said it appears that North Korea can mount a nuclear warhead on a missile, but may not have the re-entry capabilities for a strategic strike. That would include the ability of the weapon to get back through the atmosphere without burning up and the ability to hit the intended target. The official said North Korea continues to try and overcome those limitations.\n\nThe Pentagon continues to revise itscontingency plans regarding a North Korean strike, said the official, who was not authorized to discuss the issue publicly so spoke on condition of anonymity. The military routinely develops plans for all threat possibilities.\n\n“It is the threat that keeps me awake at night,” the official said, “primarily because we don’t know what the dear leader in North Korea really is after. Truthfully, they have the capability, right now, to be able to deliver a nuclear weapon. They’re just not sure about re-entry and that’s why they continue to test their systems.”\n\nU.S. officials have steadily expanded their assessments of Pyongyang’s nuclear abilities. Adm. William Gortney, then-head of U.S. Northern Command, said in March that Pyongyang may have figured out how to make a nuclear warhead small enough to fit on a long-range missile.\n\nUnder Kim Jong Un, who rose to power following his father’s death in 2011, North Korea has seen steady progress in its nuclear and missile programs, including two nuclear tests this year.\n\nThe country recently claimed a series of technical breakthroughs in its goal of developing a long-range nuclear missile capable of reaching the continental United States.\n\nNorth Korea is now “fully equipped with nuclear attack capability,” leader Kim announced proudly after the August launch of a submarine-launched missile.\n\nHe was exaggerating, but the strings of tests indicate that North Korea may have medium-range missiles capable of striking American military bases in the Pacific in the next couple years, experts say. Some believe Pyongyang may be able to hit the western United States as early as 2020.\n\nSouth Korean defense officials say North Korea doesn’t yet have such a weapon, but some civilian experts have said they believe the North has the technology to mount warheads on shorter-range Rodong and Scud missiles that can strike South Korea and Japan.\n\n“I think that they’re struggling with getting the (intercontinental ballistic missile) program up and operational,” U.S. Gen. Vincent Brooks, the head of U.S. forces in Korea, said in Senate hearings earlier this year. But “over time, I believe we’re going to see them acquire these capabilities if they’re not stopped.”\n\n“So we are in a very tenuous situation, with not a lot of leverage, not a lot of initiative in terms of negotiations,” the official who briefed Pentagon reporters said Thursday. “As you might imagine we’re preparing for contingency operations at the degree we need to.”
## 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      TEL AVIV – An Egyptian journalist wrote an op-ed claiming that Hitler only murdered between 100,000-600,000 Jews – and not six million – and that he was justified in doing so because Jews had seized control of Germany, spreading pornography and homosexuality as well as engineering the country's economic collapse.\n\nSalah Montasser's article, published earlier in the year in the Egyptian daily Al-Masri Al-Yawm and translated this week by the Middle East Media Research Institute (MEMRI), was titled “The Question that Everyone Ignores: Why Did Hitler Murder the Jews?”\n\nCiting arguments made by “a knowledgeable German friend” of his, Montasser argues that it's highly improbable that Hitler murdered six million Jews since Germany’s Jewish population before the war was less than a quarter of that number. "Jewish propaganda" helped fuel the six million myth, Montasser contends.\n\nInstead, writes Montasser, the Nazis actually killed only 100,000-600,000 Jews, a "very small" number when compared with the amount of Palestinians killed by Jews. The number of Palestinians killed is estimated to be 46,000, less than half of Montasser's figure of at least 100,000 Jewish deaths.\n\nThe "tiny minority" of Jews, writes Montasser, "managed to dominate 50% of the media, and constituted 70% of the judges."\n\n"They forced their presence upon the media, and in film, theater and literature. They were granted excessive dominance and promotion. While gaining this dominance they brought about most of the bank collapses between 1870 and 1920."\n\nMontasser continues, "They caused many financial collapses, and this is not Nazi propaganda. The Jews themselves admitted it. During this period millions of German households lost their livelihood, their savings and their investment options because of the Jewish banking gangs."\n\nMontasser also blames the Jews for impacting German psychology, which he calls "the most dangerous factor."\n\nThis included introducing pornography and homosexuality into German culture and spreading prostitution and "every kind of sexual obsession and decadent art. This is a silly kind of art, now called modern art, and it was all spread and promoted by the Jews. This caused anger and outrage among German society."\n\nMontasser's article drew sharp critiques from other figures in Egyptian media. Dr Abd Al-Mun’im Sa’id published a follow-up article in which he took Montasser to task for justifying what Hitler did to the Jews and reviving racist myths. Sa'id describes Montasser as a "friend who always stood beside me in times of need" and calls him a "liberal and a reformist." As such, writes Sa'id, Montasser's lumping of an entire group into one "monolithic unit … saying ‘the Jews said this’ or ‘the Jews did that’ contravenes the recognition that human societies contain all sorts of people." It is impossible to draw a comparison between Albert Einstein and Prime Minister Benjamin Netanyahu, writes Sa'id.\n\nSa'id also deconstructs Montasser's numbers argument, stating that the six million Jews does not refer only to German Jews, but includes all Jews in European countries occupied by the Nazis.\n\nDr. Osama Al-Ghazali Harb, another journalist and chairman of the board of Free Egyptians, Egypt's largest political party, wrote another response article, saying he was "shocked" by Montasser's claims, and fearful of the reactions they could spark among Egyptian society. He thanked Sa'id for subsequently "putting things in their rightful place."
## 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                What was life like for Russians such as Tsar Nicholas II and Vladimir Lenin in the months leading up to "the most tragic moment" of that nation's history: the Bolshevik Revolution of 1917?\n\nMikhail Zygar, a journalist from Russia has launched an ambitious social media project with the aim of answering that very question.\n\nHe set up a networking website titled 1917: Free History which is similar to Facebook with the 'friends' based on the real-life heroes and villains of the revolution.\n\nOn a timeline, the characters are posting messages, pictures and even videos in a mock-contemporaneous account of events during the weeks and months leading up to it -- all based on historical evidence.\n\n"It creates an atmosphere of this day, but 100 years ago and it gives the possibility to look at it from the inside and to learn first-hand, just what those characters were thinking, what are they afraid, or reaming of,"' Zygar told CNN.\n\nAmong them are household names: Vladimir Lenin, Tsar Nicholas II and Joseph Stalin.\n\nBringing history to life\n\nIn 1917, two revolutions overthrew the imperial government, bringing Bolshevik troops to power. Facing riots and revolt, Tsar Nicolas II abdicated his throne and along with his family, the last tsar of Russia was brutally executed the following year.\n\nLenin and Stalin were leaders of the Bolshevik Revolution, forming a provisional government that would later become the USSR.\n\nOther prominent names from early 20th century Russia feature on the site including the artist Kazimir Malevich, the author Vladimir Nabokov and ballerina Anna Pavlova.\n\nRussians are not the only nationality to feature -- Rudyard Kipling, Pablo Picasso and George V all play a prominent role too.\n\nEach character has his or her own page and all of the information has been compiled from letters, memoirs, diaries and other documents from the era.\n\nZygar explained: "There is no ability to skip days, events unfold in real time."\n\nFor example, on Thursday December 1, 1916 we find Lenin posting from Zurich in Switzerland where he was still in exile at that time. The post shows him discussing the Communist Manifesto.\n\nMeanwhile Tsar Nicholas II is also posting messages. He appears to be far from worried about an impending revolution, instead posting about his daily routine.\n\nOn December 3, 1916 he "writes" about his breakfast, a farewell to an English Admiral and taking a family member to a train station.\n\nWhen history and art collide\n\nZygar, the former editor-in-chief of TV Rain, Russia's only independent television channel, explained that the purpose of the project was to "use social media not as service but as a generator of art. To revolutionize the way of learning and teaching history."\n\nBut the project was not created for schools. Instead Zygar describes it as "educa-ment" -- a mix of education and entertainment, aimed at a much broader audience.\n\n"You can watch it as a TV show, day by day, waiting for something new and interesting to happen to your new friends."\n\nWhen asked if he felt there would be an element of nostalgia from people, he said: "It's obviously not about nostalgia because no one is feeling nostalgic about what happened 100 years ago. 1917 is the highest peak of Russian culture and civil society. It is the best and most tragic moment of Russian history."\n\nZygar adds: "The project does not have any other motive but "it's for the audience to decide what conclusion they are going to make. Do they think the middle class of 1917 resembled middle class of 2017?"\n\nAn English version of the site will due to be launched in early next year and run through until January 18 2018 -- the date the new government formed a century earlier and, as Zygar calls it, "the day of the death of Russian democracy."
## 4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             President Obama's former national security adviser said Monday that President-elect Donald Trump's phone call with the president of Taiwan should not be seen as a big deal.\n\nOffering his perspective in an interview with Fox News, retired Marine Corps General Jim Jones said, "That didn't bother me, I think the purists are flapping their wings and saying all kinds of things. Why they can't have a five minute conversation or whatever it was to say congratulations doesn't make a lot of sense to me."\n\n"I think the Trump administration will have to find whatever the right course is, and the right things during their administration, but I wouldn't prejudge what that would be right now," Jones said. "He's not the president of the United States right now, he's the president- elect. He's talking to a lot of people around the world and that's not necessarily a bad thing."\n\nTrump is the first president or president-elect to speak with a Taiwanese leader since the United States broke-off relations with Taiwan in 1979 under President Jimmy Carter, when his administration established formal relations with Beijing, marking the start of the one-China policy."\n\n"I think the policy is fine," Jones said. "I think we should lighten up a little bit about the importance of phone calls and signals that may or may not have been sent. I think policy is pretty stable and the Chinese relationship is very important."\n\nFor the first time, China sent a pair of bombers capable of launching nuclear weapons to circle Taiwan, two US officials tell Fox News. The incident occurred November 26, less than a week before Trump's controversial call Friday with the president of Taiwan, Tsai Ing-wen, angering Chinese leaders who lodged a diplomatic protest the next day.\n\nJapan scrambled eight F-15 fighter jets to intercept the two Chinese H-6K bombers and their two escort planes at one point northeast of Taiwan, according to officials.\n\nTrump's response to critics of his phone call came in a tweet Friday.\n\n"Interesting how the U.S. sells Taiwan billions of dollars of military equipment but I should not accept a congratulatory call."\n\nU.S. arms sales to Taiwan have totaled more than $46 billion since 1990. In December 2015, the United States, under President Obama, announced a $1.83 billion arms sales agreement with Taiwan, the first arms sale in four years.\n\nCritics were outraged that Trump had broken decades-long policy by speaking with Taiwan's president. When asked on CBS's "Face the Nation" Sunday if he thought Trump was speaking to the leader of a sovereign nation, Trump's future chief of staff, Reince Priebus, said, "He knew exactly what was happening. But look, we have a lot of problems to solve in this country, and we're not going to solve them by just making believe that people don't exist. This is not a massive deviation of our policy."\n\nSince the Chinese civil war in the 1940s, China and Taiwan have been ruled separately. China claims sovereignty over the island.\n\nThe White House was on the defensive Monday. White House Press Secretary Josh Earnest said officials had already made at least two calls to the Chinese.\n\n"I can confirm that U.S. officials, including senior officials on the national security council, been in touch with their Chinese counterparts to reiterate our country's continued commitment to one-China policy," he said.\n\nTrade tariffs are another point of friction. China imposes a 25 percent tariff on imported cars, for instance, while the United States has either eliminated tariffs or charges two and a half percent or less for overseas products - a huge advantage for China.\n\nThe flight around Taiwan consisted of two Chinese Xian H-6K bombers, along with two escort planes, a Tupolev Tu-154 and Shaanxi Y-8, flying around the island of Taiwan from mainland China, taking off and landing from two separate Chinese military bases.\n\nThe escort jets were used to collect radar information and conduct other surveillance on American allies such as Japan, Fox News was told. The Chinese bombers stayed in international airspace, according to officials.\n\nAt different points of the flight, Chinese J-10 and Su-30 fighter jets performed escort duties for the Chinese strategic bombers.\n\n"China has steadily built up a massive military capability in the area around Taiwan. This isn't simply a matter of flying bombers. Understand that technically, we can't object to flying bombers near Taiwan if we are flying combat aircraft and reconnaissance aircraft near China. This is simply legal under international law," said Anthony H. Cordesman, the Arleigh A. Burke Chair in Strategy at the Center for Strategic and International Studies.\n\n"Taiwan faces a much more serious Chinese challenge than it has ever faced before."\n\nJennifer Griffin currently serves as a national security correspondent for FOX News Channel . She joined FNC in October 1999 as a Jerusalem-based correspondent. You can follow her on Twitter at @JenGriffinFNC.\n\nLucas Tomlinson is the Pentagon and State Department producer for Fox News Channel. You can follow him on Twitter: @LucasFoxNews
## 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Indonesian courts have commenced the trial of Jakarta Governor Basuki “Ahok” Tjahaja Purnama, facing charges of blasphemy for having joked about a paragraph in the Quran that implies Muslims should not be governed by non-Muslims.\n\nAhok is an ethnic Chinese Christian. A video of him delivering the joke triggered a violent mob of 150,000 Indonesian Muslims to take the streets in November, demanding he be killed.\n\nPrior to the trial, Ahok, who is currently campaigning for reelection, apologized on multiple occasions. In court, he cried, insisting that he had no intention of insulting Islam and that, having been raised by Muslim adoptive parents, he respected the religion. “I did not intend to misinterpret Surah Al Maidah 51 [the Quranic verse in question] nor commit blasphemy nor insult ulemas [Islamic scholars],” Ahok told the jury. He explained that his joke was meant to target Muslim politicians who use Surah Al Maidah 51 to convince low-information voters to vote against better candidates who happen to not be Muslim.\n\nThe governor appeared to refer to Surah Al Maidah 5:51, which reads, “O you who have believed, do not take the Jews and the Christians as allies. They are [in fact] allies of one another. And whoever is an ally to them among you – then indeed, he is [one] of them. Indeed, Allah guides not the wrongdoing people.”\n\n“I referred to certain politicians who had misused Surah Al Maidah 51 to avoid fair competition prior to upcoming regional elections," Ahok argued. "When I asked my [Muslim] friends, they told me that the verse was given when there were Muslims who wanted to kill Prophet Muhammad by conspiring with Christians and Jews.”\n\n“My father and my adoptive father, vowed to be brothers until the end. The love of my adoptive parents for me, has inspired me to this day,” he added amid tears, noting that his adoptive father was Muslim.\n\nThe Jakarta Post reports that Ahok may lose his position as governor regardless of the trial outcome, at least temporarily. "If the court procures a letter explaining the charges and maximum sentence that might be given to Ahok, the Home Affairs Ministry could temporarily dismiss him,” according to a Home Affairs Ministry official.\n\nAhok was charged as a “suspect” in the blasphemy case following the aforementioned mob riot demanding his death, in which one person died. He is charged with violating an Indonesian statute that prohibits "religious abuse and/or defamation,” which carries a maximum sentence of five years.\n\nDespite the mob protests, Ahok remains extremely popular among Indonesian Christians and anti-Islamists generally. "I will keep supporting Pak Ahok who has been mistreated in this case. This is a character assassination committed by people who have ulterior motives," one supporter told the Jakarta Post at an assembly of hundreds of supporters at his campaign headquarters Thursday. Another supporter, who identified herself as Muslim, insisted she did not “feel offended by Ahok’s speech” and accused his opponents of exploiting religion to sink his campaign.\n\nThe Post also notes that a prominent women’s rights group organized in front of Ahok’s campaign headquarters to support Ahok. "We are ready to help the pair to disseminate their programs until they are elected," activist Saparinah Sadli said.\n\nIndonesia is the world’s most populous Muslim-majority nation. Its politicians have used the blasphemy law with increasing frequency in recent memory, particularly to target anti-Islamic or Westernized liberal media. In 2014, the Jakarta Post itself was charged with blasphemy for publishing an anti-Islamic State political cartoon. This year, Indonesia’s broadcasting board attempted to censor Netflix due to anti-Islamic material available on the service and have attempted to push through a ban on “offensive internet memes.”
## 6 Where should Democrats head after their recent electoral rout? As it happens, coming fights about federally subsidized health insurance offer the party a golden opportunity to engage people far beyond its urban strongholds, in communities that will be hard hit by Republican plans to shrink Medicaid, privatize Medicare and eliminate the taxes that pay for Obamacare subsidies.\n\nDonald J. Trump won the Electoral College, and Republicans maintained congressional majorities, because of overwhelming victories in small cities, outer suburbs and rural counties. Yet the president-elect and the Republicans are poised to deliver blows to the social fabric and economic underpinnings of those very communities. Along with Representative Tom Price, Mr. Trump's nominee for secretary of health and human services, congressional Republicans say they want to move quickly to revolutionize all types of federal health insurance spending, using special procedures that require only 51 votes in the Senate.\n\nCongress will be asked not only to cut the taxes levied on businesses and the rich to finance Obamacare benefits for 20 to 30 million low and middle-income Americans; Republican leaders also plan to slash federal commitments to Medicaid, giving states the authority to shrink this health care program for the poor and elderly. And Republican House members, led by Speaker Paul D. Ryan, seem determined to abolish traditional Medicare insurance for retirees and replace it with "premium vouchers" that would throw older Americans on the mercies of private insurance markets and require them to pay more for their care.\n\nTrump voters will be especially hard hit if just part of this sweeping agenda comes to fruition.\n\nConservatives often point to poor blacks and Latinos as the primary beneficiaries of federal health insurance programs. But such rhetoric obscures the enormous importance of Medicaid, Medicare and Obamacare subsidies to economically struggling white Americans living in small cities and rural areas. In Pennsylvania, where Mr. Trump narrowly beat Hillary Clinton with overwhelming support outside big cities, about 17 percent of residents are 65 or older, above the national average. Meanwhile, some 16 percent of Pennsylvanians benefit from Medicare, and 18 percent from Medicaid. With the bulk of Medicaid going to elderly and disabled residents, that program is the single largest federal subsidy flowing into the Keystone State.\n\nRepealing the Affordable Care Act would also hit Pennsylvania hard. Under the act, some 468,000 low-income Pennsylvanians had gained Medicaid coverage by August 2016, and another 439,000 bought private coverage on the Obamacare marketplace, with more than three-fourths of those people getting tax credits averaging $251 per month. Health care is often sparse in nonurban areas, and the providers that do exist depend on federal insurance programs that help many patients pay for care. If radical Republican cutbacks in federal contributions to health insurance are enacted, Pennsylvania hospitals and health care businesses will lose vital revenues, leaving many lower-income and sick Pennsylvanians at risk of losing access to care.\n\nThis is the case in other states as well, meaning many rural and small-town Trump supporters may soon see that Make America Great Again means accelerating economic decline and social devastation. Mr. Trump shows little understanding of the intricate interplay of subsidies and rules in the health care system, and probably has no inkling that federal taxes collected from liberal states like California, Massachusetts and New York heavily subsidize vital health services, businesses and family benefits in the very places that voted heavily for him. In delegating plans for huge health care cutbacks to hard-right congressional Republicans, he will be hurting his own base.\n\nBut will Mr. Trump suffer repercussions if the Republican Congress plows ahead? Its proposed changes are unpopular — including repealing the Affordable Care Act, which only one in four Americans support — and eliminating benefits usually arouses anger in the affected groups. But political punishment will not be automatic, because Democrats currently have little organized presence outside urban areas. Small cities and rural areas are overwhelmingly represented in Congress and state capitols by Republicans, who will do all they can to displace blame.\n\nFor the Democratic Party, the coming Republican assault on public health insurance represents a huge political opportunity. But to seize it, the party will have to beef up state committees and place a priority on activating volunteer supporters everywhere — getting people to write messages to local newspapers and social media sites, and reach out to hospitals, health care providers and nonprofits to beat the drums about losses the Republicans are inflicting. Even if Democrats cannot soon win outright majorities beyond their urban base, they must be actively involved in communities damaged by Mr. Trump's false campaign promises.\n\nDemocrats cannot just defend Medicare; they must loudly point out that repealing Obamacare means eliminating the taxes that subsidize health care for low- and middle-income people. That huge and immediate tax cut for the rich would lead to the demise of subsidized health insurance for millions of less privileged Americans in rural, suburban and urban communities. Proclaiming this truth could help Democrats gain a new hearing from many Trump voters. But it remains to be seen whether the party can rise to the challenge of showing up everywhere.

The code below will be used to score these documents:

from emfdscore.scoring import score_docs 

num_docs = len(template_input)

DICT_TYPE = 'emfd'
PROB_MAP = 'all'
OUT_METRICS = 'sentiment'
OUT_CSV_PATH = 'all-sent.csv'

df = score_docs(template_input,DICT_TYPE,PROB_MAP,SCORE_METHOD,OUT_METRICS,num_docs)
df.to_csv(OUT_CSV_PATH, index=False)

They run the following analysis:

    [INPUT_FILE]: = The path to a CSV file in which the first column contains the document texts to be scored.
    Each row should reflect its own document. See the template_input.csv for an example file format.

    [OUTPUT_FILE] = Specifies the file name of the generated output csv.

    [SCORING_METHOD] = Currently, eMFDscore employs three different scoring algorithms:
        bow is a classical Bag-of-Words approach in which the algorithm simply searches for word matches between document texts and the specified dictionary.
        pat (in development) relies on named entity recognition and syntactic dependency parsing. For each document, the algorithm first extracts all mentioned entities.
        Next, for each entitiy, eMFDscore extracts words that pertain to 1) moral verbs for which the entity is an agent argument (Agent verbs), 2) moral verbs for
        which the entity is the patient, theme, or other argument (Patient verbs), and other moral attributes (i.e., adjectival modifiers, appositives, etc.).
        wordlist is a simple scoring algorithm that lets users examine the moral content of individual words. This scoring method expects a CSV where each row corresponds
        to a unique word. Note: The wordlist scoring algorithm does not perform any tokenization or preprocessing on the wordlists.
        For a more fine-grained moral content extraction, users are encouraged to use either the bow or path methodology. Furthermore, only the emfd is currenlty supported for PAT extraction.
        Additionally, this method is more computationally expensive and thus has a longer execution time.
        gdelt.ngrams is designed for the Global Database of Events, Language, and Tone Television Ngram dataset.
        This scoring method expects a unigram (1gram) input text file from GDELT and will score each unprocessed (untokenized) unigram with the eMFD.

    [DICTIONARY_TYPE] = Declares which dictionary is applied to score documents. In its current version, eMFDscore lets users choose between three dictionaries:
        emfd = extended Moral Foundations Dictionary (eMFD)
        mfd2 = Moral Foundations Dicitonary 2.0 (Frimer et al., 2017; https://osf.io/xakyw/ )
        mfd = original Moral Foundations Dictionary (https://moralfoundations.org/othermaterials)

    When choosing the eMFD; the following two additional flags need to be defined:

        [PROB_MAP]: How are the foundation probabilities mapped when scoring a document?
            all : use all probabilities per word in the eMFD
            single: Assign a single probability to each word in the eMFD according to the foundation with the highest probability

        [OUTPUT_METRICS]: Which metrics are returned?
            sentiment: Return the average sentiment for each foundation
            vice-virtue: Split foundations into a vice-virtue category

Doing this returns another csv file:

sents <- read.csv("./../../../../../all-sent.csv")

What this is, is a file containing scored documents. In this case, these scores are weighted according to the probability that the words found in that document would be associated with one of five moral foundations:3

##       care_p fairness_p  loyalty_p authority_p sanctity_p   care_sent
## 1 0.13548848 0.10397791 0.09791359  0.10448576 0.08344650 -0.15196390
## 2 0.11271369 0.08739175 0.09077641  0.09835064 0.06943493 -0.14345944
## 3 0.11476923 0.10393248 0.09407835  0.09678225 0.08919876 -0.15734195
## 4 0.09014571 0.08567547 0.08608701  0.09289699 0.07070378 -0.06973861
## 5 0.09371511 0.08862730 0.09425377  0.09460122 0.07086982 -0.10924810
## 6 0.10725839 0.11048452 0.10667485  0.10633154 0.08670490 -0.17008478
##   fairness_sent loyalty_sent authority_sent sanctity_sent moral_nonmoral_ratio
## 1   -0.12298181  -0.10190735    -0.10260882   -0.11038621             2.417722
## 2   -0.06183536  -0.04672223    -0.06488811   -0.08879797             1.669903
## 3   -0.13249363  -0.07407816    -0.09160167   -0.09868642             0.791411
## 4   -0.01382498   0.01926051    -0.03055856   -0.05167584             1.051948
## 5   -0.05736668  -0.01394141    -0.03716556   -0.08602352             1.464481
## 6   -0.10215323  -0.04838916    -0.09282748   -0.09999465             1.211921
##          f_var     sent_var
## 1 3.614019e-04 0.0004330479
## 2 2.502371e-04 0.0014409332
## 3 9.884361e-05 0.0011251415
## 4 7.370221e-05 0.0011837856
## 5 1.020825e-04 0.0014373832
## 6 9.077032e-05 0.0018988651

As we can see, on average, the words in document number 1 have a probability of belonging to the care/harm moral foundation of 0.13548848 while document 2 0.11271369.

care <- sents$care_p[1:6]
## [1] 0.13548848 0.11271369 0.11476923 0.09014571 0.09371511 0.10725839

Below is a barplot showing the probability at which the average words in document 1 through 6 have of belonging to each of the five moral foundations:

fairness_p <- sents$fairness_p[1:6]

loyalty_p <- sents$loyalty_p[1:6]

authority_p <- sents$authority_p[1:6]

sanctity_p <- sents$sanctity_p[1:6]

moral_d <- data.frame(care,fairness_p,loyalty_p,authority_p,sanctity_p)
barplot(t(as.matrix(moral_d)), names.arg= c("doc 1", "doc 2", "doc 3", "doc 4", "doc 5", "doc 6"), beside = TRUE, col = c("pink", "blue", "green",  "red", "purple"))

legend(x = "bottomright", col = c("pink", "blue", "green",  "red", "purple"), lty = c(1,2,3,4,5), legend=c("care", "fairness", "loyalty", "authority", "sanctity"))


Graham, Jesse, Brian A. Nosek, Jonathan Haidt, Ravi Iyer, Spassena Koleva, and Peter H. Ditto. 2011. “Mapping the Moral Domain.” Journal of Personality and Social Psychology 101 (2): 366–85. https://doi.org/10.1037/a0021847.

Hopp, Frederic R., Jacob T. Fisher, Devin Cornell, Richard Huskey, and René Weber. 2021. “The Extended Moral Foundations Dictionary (eMFD): Development and Applications of a Crowd-Sourced Approach to Extracting Moral Intuitions from Text.” Behavior Research Methods 53 (1): 232–46. https://doi.org/10.3758/s13428-020-01433-0.

  1. Also, see for instructions. ↩︎

  2. eMFD ↩︎

  3. See Graham et al. (2011) ↩︎