if (!exists("meta") || is.null(meta)) {
  meta <- utils::packageDescription("tidyEmoji")
}
ver <- meta$Version
# Derived for the same reason the year below is: a hardcoded version is wrong
# the moment the next release opens, and nothing about citing the package would
# fail loudly enough to notice. This literal had already slipped a release.
if (is.null(ver)) {
  ver <- tryCatch(as.character(utils::packageVersion("tidyEmoji")),
                  error = function(e) NULL)
}
# Derived, not hardcoded: CRAN stamps Date/Publication at publication, so an
# installed copy cites the year it was actually published. A hardcoded year
# goes stale silently the first time the release slips past New Year.
yr <- meta$`Date/Publication`
if (is.null(yr)) yr <- meta$Date
yr <- if (!is.null(yr)) sub("-.*", "", yr) else format(Sys.Date(), "%Y")

# Every export that reads a bundled lexicon's scores is named, and a test
# derives that list from the namespace's own call graph, so a verb that starts
# reading one cannot be missed here. The header used to name three of the nine
# sentiment verbs and one of the three emotion ones.
citHeader(paste(
  "To cite tidyEmoji in publications, cite the package.",
  "If your analysis used the bundled sentiment lexicon, also cite",
  "Kralj Novak et al. (2015): that is emoji_sentiment(), emoji_score() with",
  "its default lexicon, the sentiment column of emoji_tokens(),",
  "emoji_incongruity(), emoji_congruence(), emoji_incongruity_profile(),",
  "emoji_ambiguity(), emoji_risk(), emoji_flag_ambiguous() and the",
  "novak2015 row of emoji_coverage().",
  "If it used the bundled emotion lexicon, also cite Shoeb & de Melo (2020):",
  "that is emoji_emotion(), emoji_emotion_label(),",
  "emoji_score(lexicon = \"emotag1200\") and the emotag1200 row of",
  "emoji_coverage()."
))

bibentry(
  bibtype  = "Manual",
  title    = "{tidyEmoji}: Discover, Count, Categorise, Score, Translate and Relate Emoji in Text",
  author   = person(given = "Youzhi", family = "Yu"),
  year     = yr,
  note     = if (is.null(ver)) "R package" else paste("R package version", ver),
  url      = "https://pursuitofdatascience.github.io/tidyEmoji/"
)

bibentry(
  bibtype = "Article",
  title   = "Sentiment of Emojis",
  author  = c(person(given = "Petra", family = "Kralj Novak"),
              person(given = "Jasmina", family = "Smailovic"),
              person(given = "Borut", family = "Sluban"),
              person(given = "Igor", family = "Mozetic")),
  journal = "PLoS ONE",
  year    = "2015",
  volume  = "10",
  number  = "12",
  pages   = "e0144296",
  doi     = "10.1371/journal.pone.0144296"
)

bibentry(
  bibtype   = "InProceedings",
  title     = "{EmoTag1200}: Understanding the Association between Emojis and Emotions",
  author    = c(person(given = "Abu Awal Md", family = "Shoeb"),
                person(given = "Gerard", family = "de Melo")),
  booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)",
  year      = "2020",
  pages     = "8957--8967",
  url       = "https://aclanthology.org/2020.emnlp-main.720/"
)
