当前位置: 首页>>代码示例>>Python>>正文


Python emoji.demojize方法代码示例

本文整理汇总了Python中emoji.demojize方法的典型用法代码示例。如果您正苦于以下问题:Python emoji.demojize方法的具体用法?Python emoji.demojize怎么用?Python emoji.demojize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在emoji的用法示例。


在下文中一共展示了emoji.demojize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: processing_pipelie

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def processing_pipelie(text):
    text = text.lower().strip()
    text = emoji.demojize(text, delimiters=(' ', ' '))
    text = ' '.join(text_processor.pre_process_doc(text))
    text = remove_underscope_for_emoji(text)
    return text 
开发者ID:chenyangh,项目名称:SemEval2019Task3,代码行数:8,代码来源:data_loader.py

示例2: tweet_process

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def tweet_process(text):
    text = ' '.join(text_processor.pre_process_doc(remove_tags(text)))
    text = emoji.demojize(text, delimiters=(' ', ' '))
    tokens = text.split()
    ret_list = []
    for token in tokens:
        if len(token) > 3 and '_' in token:
            token = token.replace('_', ' ')

        if token[0] == '<' and token[-1] == '>':
            token = token[1:-1]

        ret_list.append(token)
    text = ' '.join(ret_list)
    return text 
开发者ID:chenyangh,项目名称:SemEval2019Task3,代码行数:17,代码来源:tweet_processor.py

示例3: processing_pipeline

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def processing_pipeline(text):
    text = text.lower().strip()
    # text = remove_dup_emoji(text)
    text = ' '.join(text_processor.pre_process_doc(text))
    text = emoji.demojize(text, delimiters=(' ', ' '))
    text = remove_underscope_for_emoji(text)
    return text



# print(processing_pipelie('e day હત ા શ ા ર ો ગ મ ા ટ ે હ ો મ ી ય ો પ ે થ ી homeop')) 
开发者ID:chenyangh,项目名称:SemEval2019Task3,代码行数:13,代码来源:tweet_processor.py

示例4: barplot_emojis

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def barplot_emojis(msgs, your_name, target_name, topn, path_to_save):
    sns.set(style="whitegrid")

    mc_emojis = stools.get_emoji_countered(msgs).most_common(topn)
    if not mc_emojis:
        return
    your_msgs = [msg for msg in msgs if msg.author == your_name]
    target_msgs = [msg for msg in msgs if msg.author == target_name]

    your_emojis_cnt = stools.get_emoji_countered(your_msgs)
    target_emojis_cnt = stools.get_emoji_countered(target_msgs)

    df_dict = {"name": [], "emoji": [], "num": []}
    for e, _ in mc_emojis:
        df_dict["emoji"].extend([emoji.demojize(e), emoji.demojize(e)])
        df_dict["name"].append(your_name)
        df_dict["num"].append(your_emojis_cnt[e])
        df_dict["name"].append(target_name)
        df_dict["num"].append(target_emojis_cnt[e])

    ax = sns.barplot(x="num", y="emoji", hue="name", data=pd.DataFrame(df_dict), palette="PuBu")
    ax.set(ylabel="emoji name", xlabel="emojis")
    ax.legend(ncol=1, loc="lower right", frameon=True)

    fig = plt.gcf()
    fig.set_size_inches(11, 8)
    plt.tight_layout()

    fig.savefig(os.path.join(path_to_save, barplot_emojis.__name__ + ".png"), dpi=500)
    # plt.show()
    log_line(f"{barplot_emojis.__name__} was created.")
    plt.close("all") 
开发者ID:vlajnaya-mol,项目名称:message-analyser,代码行数:34,代码来源:plotter.py

示例5: __init__

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def __init__(self, client, name, team, match, skin):
        self.client = client
        self.server = client.server
        self.match = match
        self.skin = skin
        
        self.name = ' '.join(emoji.emojize(re.sub(r"[^\x00-\x7F]+", "", emoji.demojize(name)).strip())[:20].split()).upper()
        self.team = team
        if len(self.team) > 0 and self.server.checkCurse(self.name):
            self.name = str()
        if len(self.name) == 0:
            self.name = self.server.defaultName
        self.pendingWorld = None
        self.level = int()
        self.zone = int()
        self.posX = int()
        self.posY = int()
        self.dead = True
        self.win = bool()
        self.voted = bool()
        self.loaded = bool()
        self.lobbier = bool()
        self.lastUpdatePkt = None

        self.trustCount = int()
        self.lastX = int()
        self.lastXOk = True
        
        self.id = match.addPlayer(self) 
开发者ID:Igoorx,项目名称:PyRoyale,代码行数:31,代码来源:player.py

示例6: is_unicode

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def is_unicode(text):
    demojized = demojize(text)
    if demojized.count(':') != 2:
        return False
    if demojized.split(':')[2] != '':
        return False
    return demojized != text 
开发者ID:Toaster192,项目名称:rubbergod,代码行数:9,代码来源:karma.py

示例7: _

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    if event.reply_to_msg_id:
        previous_message = await event.get_reply_message()
        text = previous_message.message
        lan = input_str or "ml"
    elif "|" in input_str:
        lan, text = input_str.split("|")
    else:
        await event.edit("`.tr LanguageCode` as reply to a message")
        return
    text = emoji.demojize(text.strip())
    lan = lan.strip()
    translator = Translator()
    try:
        translated = translator.translate(text, dest=lan)
        after_tr_text = translated.text
        # TODO: emojify the :
        # either here, or before translation
        output_str = """**TRANSLATED** from {} to {}
{}""".format(
            translated.src,
            lan,
            after_tr_text
        )
        await event.edit(output_str)
    except Exception as exc:
        await event.edit(str(exc)) 
开发者ID:mkaraniya,项目名称:BotHub,代码行数:32,代码来源:translate.py

示例8: deform_emojis

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def deform_emojis(text):
    """ Convert unicode emojis into their text form """
    new_text = ""
    emojiless_text = ""
    data = regex.findall(r"\X", text)
    emojis_in_text = []

    for word in data:
        if any(char in UNICODE_EMOJI for char in word):
            word_emoji = emoji.demojize(word).replace(":", "").replace("_", " ")
            if word_emoji not in emojis_in_text:  # do not add an emoji if
                # already exists in text
                emojiless_text += " "
                new_text += " ({}) ".format(word_emoji)
                emojis_in_text.append(word_emoji)
            else:
                emojiless_text += " "
                new_text += " "  # add a space [instead of an emoji to be
                # duplicated]

        else:
            new_text += word
            emojiless_text += word

    emojiless_text = remove_extra_spaces(emojiless_text)
    new_text = remove_extra_spaces(new_text)

    return new_text, emojiless_text 
开发者ID:Instagram-Tools,项目名称:bot,代码行数:30,代码来源:util.py

示例9: _

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def _(event):
    if event.fwd_from:
        return
    if "trim" in event.raw_text:
        # https://t.me/c/1220993104/192075
        return
    input_str = event.pattern_match.group(1)
    if event.reply_to_msg_id:
        previous_message = await event.get_reply_message()
        text = previous_message.message
        lan = input_str or "ml"
    elif "|" in input_str:
        lan, text = input_str.split("|")
    else:
        await event.edit("`.tr LanguageCode` as reply to a message")
        return
    text = emoji.demojize(text.strip())
    lan = lan.strip()
    translator = Translator()
    try:
        translated = translator.translate(text, dest=lan)
        after_tr_text = translated.text
        # TODO: emojify the :
        # either here, or before translation
        output_str = """**TRANSLATED** from {} to {}
{}""".format(
            translated.src,
            lan,
            after_tr_text
        )
        await event.edit(output_str)
    except Exception as exc:
        await event.edit(str(exc)) 
开发者ID:Dark-Princ3,项目名称:X-tra-Telegram,代码行数:35,代码来源:translate.py

示例10: parse_comment_for_vote

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def parse_comment_for_vote(body):
    """ turns a comment into a vote, if possible """
    return parse_emojis_for_vote(demojize(body)) 
开发者ID:Chaosthebot,项目名称:Chaos,代码行数:5,代码来源:voting.py

示例11: top_emojis

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def top_emojis(self, nbr):
        """Returns the top `nbr` emojis used and who sent them.

        Args:
            nbr (int): The number of emojis to include in top list.

        Returns:
            tuple: List of top emojis and dict showing how many of
                these were sent by each participant.

        """
        emojis = {e: 0 for e in iter(emoji.UNICODE_EMOJI.values())}
        emojis_p = {p: 0 for p in self.p}
        for p in emojis_p:
            emojis_p[p] = {e: 0 for e in iter(emoji.UNICODE_EMOJI.values())}
        for message in self.data['messages']:
            if 'content' in message and len(message) == 4:
                msg = message['content']
                sender = message['sender_name']
                for c in msg:
                    emoji_str = emoji.demojize(c)
                    if emoji_str in emojis:
                        emojis_p[sender][emoji_str] += 1
                        emojis[emoji_str] += 1
        top_emojis = [emoji_key for emoji_key, count in sorted(emojis.items(),
                                       key=lambda kv: (-kv[1], kv[0]))[:nbr]]
        emojis_count_p = {p: {} for p in self.p}
        for p in self.p:
                emojis_count_p[p] = [emojis_p[p][e] for e in top_emojis]
        top_emojis = [emoji.emojize(top_emoji) for top_emoji in top_emojis]
        return top_emojis, emojis_count_p 
开发者ID:davidkrantz,项目名称:FacebookChatStatistics,代码行数:33,代码来源:facebook_messenger_conversation.py

示例12: build_say_payload

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def build_say_payload(self, room, bot, text, apikey):
        """ Lingr """
        demoji = emoji.demojize(text)

        return {
            'room': room,
            'bot': bot,
            'text': demoji,
            'bot_verifier': hashlib.sha1(bot + apikey).hexdigest(),
        } 
开发者ID:tinbotu,项目名称:sub,代码行数:12,代码来源:sun.py

示例13: say

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def say(self, slack=False, lingr=True):
        resp = "\n".join(tuple(self.response())).rstrip("\n")
        if slack:
            j = {}
            j["text"] = resp
            print(json.dumps(j))
            # Lingr にも話す
            self.sub.say_lingr(message=resp, anti_double=False)
            lingr = False

        if lingr:
            resp_demoji = emoji.demojize(resp)
            print(resp_demoji, end='')
            if not self.passerby_channel:
                self.sub.say_slack(message=resp, anti_double=False) 
开发者ID:tinbotu,项目名称:sub,代码行数:17,代码来源:sun.py

示例14: comment_image

# 需要导入模块: import emoji [as 别名]
# 或者: from emoji import demojize [as 别名]
def comment_image(browser, username, comments, blacklist, logger, logfolder, Settings):
    """Checks if it should comment on the image"""
    # check action availability
    if quota_supervisor(Settings, "comments") == "jump":
        return False, "jumped"

    rand_comment = random.choice(comments).format(username)
    rand_comment = emoji.demojize(rand_comment)
    rand_comment = emoji.emojize(rand_comment, use_aliases=True)

    open_comment_section(browser, logger)
    comment_input = get_comment_input(browser)

    try:
        if len(comment_input) > 0:
            comment_input[0].clear()
            comment_input = get_comment_input(browser)
            # below, an extra space is added to force
            # the input box to update the reactJS core
            comment_to_be_sent = rand_comment + " "

            browser.execute_script(
                "arguments[0].value = arguments[1];",
                comment_input[0],
                comment_to_be_sent,
            )
            # below, it also will remove that extra space added above
            # COS '\b' is a backspace char in ASCII
            comment_input[0].send_keys("\b")
            comment_input = get_comment_input(browser)
            comment_input[0].submit()
            update_activity(Settings, "comments")

            if blacklist["enabled"] is True:
                action = "commented"
                add_user_to_blacklist(
                    username, blacklist["campaign"], action, logger, logfolder
                )
        else:
            logger.warning(
                "--> Comment Action Likely Failed!" "\t~comment Element was not found"
            )
            return False, "commenting disabled"

    except InvalidElementStateException:
        logger.warning(
            "--> Comment Action Likely Failed!"
            "\t~encountered `InvalidElementStateException` :/"
        )
        return False, "invalid element state"

    logger.info("--> Commented: {}".format(rand_comment.encode("utf-8")))

    # get the post-comment delay time to sleep
    naply = get_action_delay("comment", Settings)
    sleep(naply)

    return True, "success" 
开发者ID:ishandutta2007,项目名称:FacebookPy,代码行数:60,代码来源:comment_util.py


注:本文中的emoji.demojize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。