Detecting Politeness Features in Text

Detecting markers of politeness in English natural language. This package allows researchers to easily visualize and quantify politeness between groups of documents. This package combines prior research on the linguistic markers of politeness (Brown & Levinson, 1987 < http://psycnet.apa.org/record/1987-97641-000>; Danescu-Niculescu-Mizil et al., 2013 ; Voigt et al., 2017 ). We thank the Spencer Foundation, the Hewlett Foundation, and Harvard's Institute for Quantitative Social Science for support.


Politeness is a universal dimension of langauge (Lakoff, 1973; Brown & Levinson, 1987). In practically all communication, a speaker can choose to be more or less polite to their audience. In this package, we provide tools for researchers to measure the markers and effects of politeness in natural language.

Installation

You can install politeness directly, like so:

 install.packages("politeness")

Many of the politeness features containted in this package use some part-of-speech tagging. We recommend SpaCy, which is simple to install through python and which has a convenient wrapper function for use through R, SpaCyR. If you do not have SpaCy installed you must do it outside of R first - otherwise, a reduced set of features (i.e. those that do not require part-of-speech tags) is provided by the package.

Example

In the package we have included a dataset, phone_offers. It was collected from an experiment in which participants were told to write offers asking to buy a smartphone from a seller on Craigslist. We randomly manipulated their instructions so that their task was to write in a warm or tough style. The dataset includes the text of their messages, as well as the condition assignment.

data("phone_offers")
 
politeness::politeness(phone_offers$message)
#spacyr::spacy_initialize(python_executable = "PYTHON_PATH")
#politeness::politeness(phone_offers$message, parser="spacy")
 
politeness::politenessPlot(politeness::politeness(phone_offers$message),
                           split=phone_offers$condition,
                           split_levels = c("Warm","Tough"),
                           split_name = "Condition")

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("politeness")

0.4.1 by Mike Yeomans, 2 months ago


Browse source code at https://github.com/cran/politeness


Authors: Mike Yeomans , Alejandro Kantor , Dustin Tingley


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports tm, quanteda, ggplot2, parallel, spacyr, textir, glmnet, data.table, stringr

Suggests knitr, rmarkdown, testthat


See at CRAN