Skip to content

v0.3.0

Choose a tag to compare

@PursuitOfDataScience PursuitOfDataScience released this 04 Aug 16:21
· 108 commits to main since this release

New features

  • emoji_emotion() scores each row's emoji across the eight Plutchik emotions
    (anger, anticipation, disgust, fear, joy, sadness, surprise, trust), using the
    new bundled emoji_emotion_lexicon (EmoTag1200, Shoeb & de Melo 2020, MIT).
    Supports a long form (long = TRUE) with one row per (row, emotion).
  • emoji_emotion_label() adds the dominant emotion per row.
  • A pluggable lexicon API: emoji_lexicons() lists bundled and registered
    lexicons, register_emoji_lexicon() adds your own, and emoji_score() is the
    generic scorer all the verbs share. emoji_sentiment() gains a lexicon
    argument (default "novak2015", unchanged behaviour).
  • Relational analysis. emoji_pairs() returns a tidy, graph-ready edge list
    (item1, item2, n) of the emoji that co-occur in the same document —
    each row is a document, or supply doc_id to pool rows — with
    directed = TRUE to order pairs by first appearance. emoji_cooccurrence()
    is the same with an optional diagonal (each emoji's document frequency).
    emoji_ngrams() slides a window over each row's emoji in reading order and
    returns one row per consecutive n-gram.
  • Structural metrics. emoji_position() reports where emoji sit in each text
    (first/last character position and mean relative position in [0, 1]),
    emoji_density() reports emoji per character and per token, and
    emoji_ratio() reports the share of the text's characters that are emoji
    plus an .emoji_only flag.
  • emoji_dfm() builds a document-by-emoji feature table (weightings: counts,
    binary, tf-idf), keeping every document — including emoji-free ones — so the
    result binds row-for-row to outcome columns in modelling workflows.
  • The corpus-level verbs above (emoji_pairs(), emoji_cooccurrence(),
    emoji_ngrams(), emoji_dfm()) canonicalise glyphs through the package's
    codepoint key, so qualified and unqualified forms of the same emoji (for
    example the victory hand with and without U+FE0F) count as one
    node/feature. emoji_frequency() intentionally still reports the exact
    extracted glyph.
  • emoji_to_text() replaces emoji in a text column with their Unicode names or
    shortcodes (demojize — useful for accessibility and NLP preprocessing), and
    text_to_emoji() is the inverse (emojize).
  • Vector helpers as_emoji_name(), as_emoji_shortcode() and as_emoji() for
    ad-hoc conversion.
  • emoji_search() finds emoji by keyword, name or shortcode and returns a tidy
    tibble of matches.
  • New bundled dataset emoji_emotion_lexicon.
  • tidyEmoji has a hex logo! It appears in the README and on the pkgdown site
    (man/figures/logo.svg is the vector master, logo.png the raster copy).

Improvements and fixes

  • Grapheme-aware detection now covers newer zero-width-joiner sequences.
    The upstream emoji regex only knows the ZWJ sequences that were current when
    it was built, so it reported later ones — face exhaling, face with spiral
    eyes, heart on fire, people holding hands, the skin-toned handshakes,
    "woman: blond hair", and around 630 others — as their component emoji.
    tidyEmoji now re-joins them (a ZWJ between two emoji always binds them into
    one grapheme cluster). Previously such an emoji inflated counts, resolved to
    the wrong name, split into several co-occurrence nodes and stopped
    emoji_ratio() recognising an emoji-only row; all of that is fixed. Emoji
    separated by anything other than a ZWJ are unaffected.
  • Extraction and location are now sliced from the same spans, so no verb can
    disagree with another about where an emoji starts and ends.
  • text_to_emoji() no longer misses a :shortcode: that follows an unrelated
    colon. "meet at 10:30 :grinning:" and "https://example.org :grinning:"
    previously came back unchanged, because the permissive :...: pattern
    consumed the shortcode's opening colon; shortcode tokens are now matched on
    the character set GitHub-style aliases actually use.
  • emoji_pairs() and emoji_dfm() order glyphs in the C locale, so which
    glyph lands in item1 and the order of a dfm's tied columns no longer depend
    on the session's collation. Results are now reproducible across machines.
  • emoji_lexicons() no longer reports the glyph column as a score dimension
    for a lexicon registered with a by other than "emoji".
  • emoji_emotion(long = TRUE) no longer drops a user column named
    .row_number.
  • emoji_ngrams(n = Inf) gives the documented error instead of a coercion
    warning followed by "missing value where TRUE/FALSE needed".
  • emoji_to_text() is several times faster: it locates emoji once for the
    whole column rather than once per row.
  • emoji_density() returns .emoji_per_token = 0 (not NA) for
    whitespace-only text, matching .emoji_per_char and the documented
    "no emoji -> 0" contract (#1).
  • as_emoji() accepts the spaced Unicode names produced by as_emoji_name()
    (routing through the reference table), so as_emoji(as_emoji_name(x))
    round-trips instead of returning NA (#2).
  • ?emoji_sentiment_lexicon now explains which lexicon entries are stored as
    unqualified, text-presentation code points (the bare heart U+2764 without
    U+FE0F, the white smiling face, the heavy check mark, ...) and are
    therefore not detected in text, and notes that the qualified form resolves to
    the same entry (#3).
  • The help pages no longer embed raw emoji glyphs, so the reference manual
    builds as PDF; ?register_emoji_lexicon no longer points at an internal
    development file.
  • emoji_search() matches literally, so queries containing regex
    metacharacters (for example the +1 alias) are safe and cannot error.
  • emoji_to_text(format = "shortcode") now always emits the emoji's canonical
    (first) GitHub-style alias — the same one reported by emoji_frequency() and
    as_emoji_shortcode() — and the wrap template is honoured. Emoji with no
    known name/shortcode are left in place rather than dropped from the text.
  • emoji_to_text() and text_to_emoji() keep NA text entries as NA.
  • emoji_emotion() and emoji_emotion_label() accept registered or
    data-frame emotion lexicons (any subset of the eight Plutchik dimensions),
    not just the bundled "emotag1200".
  • Registered lexicons resolve through their stored normalised key, so
    register_emoji_lexicon(by = ) works with any glyph column name in
    emoji_sentiment() and emoji_emotion().
  • emoji_frequency() (and therefore top_n_emojis()) breaks count ties by
    the glyph, making the output order deterministic.
  • emoji_lexicons() no longer lists a custom lexicon's glyph/key columns among
    its score dimensions.
  • The package help page (?tidyEmoji) documents the output and naming
    contract shared by all verbs.
  • rlang moved from Suggests to Imports (tidy-eval capture of the new optional
    doc_id argument); it was already a hard transitive dependency, so the
    installed footprint is unchanged.
  • Grouped data frames passed to emoji_pairs(), emoji_cooccurrence() or
    emoji_dfm() warn that grouping is ignored — use doc_id to express
    per-group structure.
  • The vignette header no longer carries a build date.
  • DESCRIPTION Title and Description broadened to cover emotions, translation,
    search, co-occurrence, structural metrics and feature tables; version bumped
    to 0.3.0.