findPoliteTexts {politeness} | R Documentation |
Find polite text
Description
Finds examples of most or least polite text in a corpus
Usage
findPoliteTexts(
text,
df_polite,
covar,
type = c("most", "least", "both"),
num_docs = 5L,
...
)
Arguments
text |
a character vector of texts. |
df_polite |
a data.frame with politeness features, as outputed by |
covar |
a vector of politeness labels, or other covariate. |
type |
a string indicating if function should return the most or least polite texts or both. If |
num_docs |
integer of number of documents to be returned. Default is 5. |
... |
additional parameters to be passed to |
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)
findPoliteTexts(phone_offers$message,
polite.data,
phone_offers$condition,
type = "most",
num_docs = 5)
findPoliteTexts(phone_offers$message,
polite.data,
phone_offers$condition,
type = "least",
num_docs = 10)