emoji_risk() scores how likely each row's emoji are to be misread, using
the annotation-disagreement statistics of emoji_ambiguity(). It is the
content-QA counterpart of emoji_sentiment(): a row can carry a confident
positive score built entirely out of glyphs its annotators fought over.
Arguments
- data
A data frame or tibble containing a text column. Grouped data frames are accepted. The verbs that work a row at a time (adding columns, or keeping and expanding rows) carry the grouping through to their result, as
dplyr::mutate()anddplyr::filter()do. The verbs that pool across rows – the counts, the co-occurrence edge lists, the time series – warn that they ignore the grouping and return one corpus-wide answer.- text
The text column to scan, supplied unquoted. Any atomic column is accepted and read as character, so a
factorworks and a numeric,Dateor logical one simply contains no emoji. A list column – or a data-frame column – is refused rather than coerced, because coercing one deparses it and the emoji found would be in the code rather than in your data. What counts as an emoji is the same in every verb; see the Detection section of tidyEmoji for the one case that surprises people, code points that are emoji only when they carryU+FE0F.- measure
Ambiguity statistic to use; see
emoji_ambiguity().- threshold
Value at or above which a glyph counts as ambiguous.
NULL(default) uses the lexicon's upper quartile ofmeasure.
Value
data, as a tibble, with added columns .emoji_n,
.emoji_n_scored, .emoji_ambiguity_mean, .emoji_ambiguity_max and
.emoji_n_ambiguous. Rows with no emoji get NA throughout. A row that
has emoji the lexicon cannot score gets .emoji_n_scored = 0,
.emoji_n_ambiguous = 0 and NA for the two averages – there is nothing
to average, but the count of ambiguous glyphs found is genuinely zero.
Details
threshold decides what counts as an ambiguous glyph for
.emoji_n_ambiguous. The default, NULL, uses the upper quartile of the
chosen measure across the whole lexicon, i.e. "in the most-disputed quarter
of all emoji". Supply your own number to make the cut-off explicit in your
script.
Emoji absent from the lexicon cannot be scored and are excluded from the
means; .emoji_n and .emoji_n_scored together show how much of the row
was actually measured.
Examples
df <- data.frame(text = c("thanks \U0001f643", "great \U0001f600", "plain"))
emoji_risk(df, text)
#> # A tibble: 3 × 6
#> text .emoji_n .emoji_n_scored .emoji_ambiguity_mean .emoji_ambiguity_max
#> <chr> <int> <int> <dbl> <dbl>
#> 1 thanks 🙃 1 0 NA NA
#> 2 great 😀 1 1 0.835 0.835
#> 3 plain 0 NA NA NA
#> # ℹ 1 more variable: .emoji_n_ambiguous <int>