bool IsEmoticon()

in tensorflow_text/core/kernels/sentence_fragmenter_v2.cc [184:344]


bool IsEmoticon(const absl::string_view& input, int* offset) {
  *offset = 0;
  static std::vector<std::string> emoticon_list = {":(:)",
                                                   ":)",
                                                   ":(",
                                                   ":o)",
                                                   ":]",
                                                   ":3",
                                                   ":>",
                                                   "=]",
                                                   "=)",
                                                   ":}",
                                                   ":^)",
                                                   ":-D",
                                                   ":-)))))",
                                                   ":-))))",
                                                   ":-)))",
                                                   ":-))",
                                                   ":-)",
                                                   ">:[",
                                                   ":-(",
                                                   ":(",
                                                   ":-c",
                                                   ":c",
                                                   ":-<",
                                                   ":<",
                                                   ":-[",
                                                   ":[",
                                                   ":{",
                                                   ";(",
                                                   ":-||",
                                                   ":@",
                                                   ">:(",
                                                   ":'-(",
                                                   ":'(",
                                                   ":'-)",
                                                   ":')",
                                                   "D:<",
                                                   ">:O",
                                                   ":-O",
                                                   ":-o",
                                                   ":*",
                                                   ":-*",
                                                   ":^*",
                                                   ";-)",
                                                   ";)",
                                                   "*-)",
                                                   "*)",
                                                   ";-]",
                                                   ";]",
                                                   ";^)",
                                                   ":-,",
                                                   ">:P",
                                                   ":-P",
                                                   ":p",
                                                   "=p",
                                                   ":-p",
                                                   "=p",
                                                   ":P",
                                                   "=P",
                                                   ";p",
                                                   ";-p",
                                                   ";P",
                                                   ";-P",
                                                   ">:\\",
                                                   ">:/",
                                                   ":-/",
                                                   ":-.",
                                                   ":/",
                                                   ":\\",
                                                   "=/",
                                                   "=\\",
                                                   ":|",
                                                   ":-|",
                                                   ":$",
                                                   ":-#",
                                                   ":#",
                                                   "O:-)",
                                                   "0:-)",
                                                   "0:)",
                                                   "0;^)",
                                                   ">:)",
                                                   ">;)",
                                                   ">:-)",
                                                   "}:-)",
                                                   "}:)",
                                                   "3:-)",
                                                   ">_>^",
                                                   "^<_<",
                                                   "|;-)",
                                                   "|-O",
                                                   ":-J",
                                                   ":-&",
                                                   ":&",
                                                   "#-)",
                                                   "<3",
                                                   "8-)",
                                                   "^_^",
                                                   ":D",
                                                   ":-D",
                                                   "=D",
                                                   "^_^;;",
                                                   "O=)",
                                                   "}=)",
                                                   "B)",
                                                   "B-)",
                                                   "=|",
                                                   "-_-",
                                                   "o_o;",
                                                   "u_u",
                                                   ":-\\",
                                                   ":s",
                                                   ":S",
                                                   ":-s",
                                                   ":-S",
                                                   ";*",
                                                   ";-*"
                                                   "=(",
                                                   ">.<",
                                                   ">:-(",
                                                   ">:(",
                                                   ">=(",
                                                   ";_;",
                                                   "T_T",
                                                   "='(",
                                                   ">_<",
                                                   "D:",
                                                   ":o",
                                                   ":-o",
                                                   "=o",
                                                   "o.o",
                                                   ":O",
                                                   ":-O",
                                                   "=O",
                                                   "O.O",
                                                   "x_x",
                                                   "X-(",
                                                   "X(",
                                                   "X-o",
                                                   "X-O",
                                                   ":X)",
                                                   "(=^.^=)",
                                                   "(=^..^=)",
                                                   "=^_^=",
                                                   "-<@%",
                                                   ":(|)",
                                                   "(]:{",
                                                   "<\\3",
                                                   "~@~",
                                                   "8'(",
                                                   "XD",
                                                   "DX"};

  for (int i = 0; i < static_cast<int>(emoticon_list.size()); ++i) {
    if (absl::StartsWith(input, emoticon_list[i])) {
      *offset = emoticon_list[i].length();
      return true;
    }
  }
  return false;
}