exampleTexts: Find polite text

View source: R/exampleTexts.R

exampleTextsR Documentation

Find polite text

Description

Finds examples of most or least polite text in a corpus

Usage

exampleTexts(text, covar, type = c("most", "least"), num_docs = 5L)

Arguments

text

a character vector of texts.

covar

a vector of politeness labels (from human or model), or other covariate.

type

a string indicating if function should return the most or least polite texts or both. If length > 1 only first value is used.

num_docs

integer of number of documents to be returned. Default is 5.

Details

Function returns a data.frame ranked by (more or least) politeness. If type == 'most', the num_docs most polite texts will be returned. If type == 'least', the num_docs least polite texts will be returned. If type == 'both', both most and least polite text will be returned. if num_docs is even, half will be most and half least polite else half + 1 will be most polite.

df_polite must have the same number of rows as the length(text) and length(covar).

Value

data.frame with texts ranked by (more or least) politeness. See details for more information.

Examples


data("phone_offers")
polite.data<-politeness(phone_offers$message, parser="none",drop_blank=FALSE)

exampleTexts(phone_offers$message,
                phone_offers$condition,
                type = "most",
                num_docs = 5)

exampleTexts(phone_offers$message,
                phone_offers$condition,
                type = "least",
                num_docs = 10)


politeness documentation built on April 4, 2025, 2:44 a.m.