- This is forked version from emfdscore.
- compatible with latest spacy and pandas package
score_docs
using column index for scoring- Only support bow score type
- make sure your python version >=3.12 in your environment. The another might work
python3 --version
- install
spacy
anden_core_web_sm
, see spacy usage
pip install emfd
- emfd
import pandas as pd
from emfd.scoring import score_docs
df = pd.read_csv("your_data_set.csv")
num_docs = len(df)
DICT_TYPE = 'emfd'
PROB_MAP = 'all' # or single
SCORE_METHOD = 'bow' # or more options see documents, only bow tested currently
OUT_METRICS = 'sentiment' # or vice-virtue
OUT_CSV_PATH = './your_file_output.csv'
column_index = 0 # the columen number of content for scoring
df = score_docs(df,DICT_TYPE,PROB_MAP,SCORE_METHOD,OUT_METRICS,num_docs,column_index)
df.to_csv(OUT_CSV_PATH, index=False)
polars
implementations- vectorized operations
When using eMFDscore, please consider giving this repository a star (top right corner) and citing the following article:
Hopp, F. R., Fisher, J. T., Cornell, D., Huskey, R., & Weber, R. (2020). The extended Moral Foundations Dictionary (eMFD): Development and applications of a crowd-sourced approach to extracting moral intuitions from text. Behavior Research Methods, https://doi.org/10.3758/s13428-020-01433-0
eMFDscore is dual-licensed under GNU GENERAL PUBLIC LICENSE 3.0, which permits the non-commercial use, distribution, and modification of the eMFDscore package. Commercial use of the eMFDscore requires an application.
The eMFD has been used in the following applications (ordered by date of publication):
- Harris, C., Myers, A., & Kaiser, A. (2022). Being Seen: How Markets Impact Our Moral Sentiments. Available at SSRN: https://ssrn.com/abstract=3997378 or http://dx.doi.org/10.2139/ssrn.3997378
- Malik, M., Hopp, F. R., Chen, Y., & Weber, R. (2021). Does Regional Variation in Pathogen Prevalence Predict the Moralization of Language in COVID-19 News? Journal of Language and Social Psychology.
- Chen, Kaiping, Zening Duan, and Sijia Yang. "Twitter as research data: Tools, costs, skill sets, and lessons learned." Politics and the Life Sciences (2021): 1-17.
- Van Vliet, L. (2021). Moral expressions in 280 characters or less: An Analysis of Politician tweets following the 2016 Brexit referendum vote. Frontiers in Big Data, 4, 49.
- Priniski, J. H., Mokhberian, N., Harandizadeh, B., Morstatter, F., Lerman, K., Lu, H., & Brantingham, P. J. (2021). Mapping Moral Valence of Tweets Following the Killing of George Floyd. arXiv preprint arXiv:2104.09578.
- Hopp, F. R., Fisher, J. T., & Weber, R. (2020). A graph-learning approach for detecting moral conflict in movie scripts. Media and Communication, 8(3), 164.