Learn R Programming

⚠️There's a newer version (0.9.4) of this package.Take me there.

Politeness

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 dependency parsing. We rely on the popular python library SpaCy, which is simple to install, although the procedure can vary for different machines. Our software depends on a convenient wrapper function, spacyr, that also includes several intallation tools. If you do not have SpaCy installed, a reduced set of features is provided (i.e. those that do not require dependency tags) but this only recommended for initial tests, rather than final analyses.

Please confirm that your machine can run SpaCy and spacyr first! This step can be difficult for some machines, and we defer to the existing documentation for that software as a guide. Users may also want to consider RStudio Cloud, which can support all of this software without local installation issues.

Citation

If you find this package useful, please cite us, using the following reference from our R Journal publication.

Yeomans, M., Kantor, A. & Tingley, D. (2018). Detecting Politeness in Natural Language. The R Journal, 10(2), 489-502.

Note that this publication was written using version 0.2.4 of the package. For the most up-to-date description of the functionality, please see the vignette in this repository.

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)

# install.packages("spacyr")
#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")

Copy Link

Version

Install

install.packages('politeness')

Monthly Downloads

498

Version

0.8.7

License

MIT + file LICENSE

Maintainer

Mike Yeomans

Last Published

June 28th, 2022

Functions in politeness (0.8.7)

cleantext

Clean Text
ctxpand

Contraction Expander
findPoliteTexts

Find polite text
politeness

Politeness Features
politenessPlot

Politeness plot
politenessProjection

Politeness projection
bowl_offers

Purchase offers for bowl
hedge_list

Hedge Words List
foldset

Fold Assignment for Cross-Validation
feature_table

Table of Politeness Features
cleanpunct

Cleaning weird encodings
getTokenSets

Extracting Tokens from Natural Language
phone_offers

Purchase offers for phone
dictWrap

Dictionary Wrapper
polite_dicts

Feature Dictionaries
receptive_polite

Pre-Trained Receptiveness Data
negative_list

Negative Emotions List
receptiveness

Conversational Receptiveness
receptive_train

Pre-Trained Receptiveness Data
usWords

UK to US conversion
positive_list

Positive Emotions List
slogodds

Variance-Weighted Log Odds
spacyParser

Spacy Parser
uk2us

UK to US Conversion dictionary
textcounter

Text Counter