Which emoji in this corpus are most likely to be misread?
Source:R/emoji-ambiguity.R
emoji_flag_ambiguous.Rdemoji_flag_ambiguous() crosses the emoji actually present in a text column
with their annotation-disagreement statistics and returns the most ambiguous
ones first. It is the content-QA shortlist: the glyphs worth a second look
before a campaign ships or a coding scheme is fixed.
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.- top_n
Number of emoji to return, most ambiguous first.
NULLreturns all of them. When a tie straddles the cut the glyph decides which emoji fall inside it, in the C locale, as intop_n_emojis(); a corpus with fewer emoji than this returns every one of them rather than padding, and0returns no rows at all.- measure
Ambiguity statistic to rank by; see
emoji_ambiguity().
Value
A tibble with columns emoji, name, n (occurrences in the
corpus), n_annotations, ambiguity and rank (the glyph's rank in the
whole lexicon, carried over from emoji_ambiguity(), so tied glyphs share
a rank). Rows are ordered by descending ambiguity, then descending n,
then the glyph, so the order is deterministic. Emoji absent from the
lexicon cannot be ranked and are dropped.
Examples
df <- data.frame(text = c("ok \U0001f643", "yay \U0001f600 \U0001f643",
"hmm \U0001f612"))
emoji_flag_ambiguous(df, text, top_n = 3)
#> # A tibble: 2 × 6
#> emoji name n n_annotations ambiguity rank
#> <chr> <chr> <int> <int> <dbl> <int>
#> 1 😒 unamused face 1 1385 0.959 233
#> 2 😀 grinning face 1 439 0.835 410