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


Java EmojiParser.removeAllEmojis方法代码示例

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


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

示例1: wordCountEmojiAndVocab

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
/**
 * Counts the amount of words and emojis. If the word is no stop word, it gets added to the vocabulary.
 * Grouped together for performance reasons.
 *
 * @param globalStatistics
 * @param message
 */
private void wordCountEmojiAndVocab(GlobalStatistics globalStatistics, Message message) {
    List<EmojiParser.UnicodeCandidate> emojis = EmojiParser.getUnicodeCandidates(message.getContent());

    for (EmojiParser.UnicodeCandidate uc : emojis) {
        globalStatistics.getStatistics().incrementEmoji(uc.getEmoji().getUnicode());
        message.getSender().getStatistics().incrementEmoji(uc.getEmoji().getUnicode());
    }

    String cleanMessage = EmojiParser.removeAllEmojis(message.getContent());
    cleanMessage = this.cleaningPattern1.matcher(cleanMessage).replaceAll("");
    cleanMessage = this.cleaningPattern2.matcher(cleanMessage).replaceAll("");



    if (!cleanMessage.isEmpty()) {
        String[] allWords = cleanMessage.split("\\s+");
        globalStatistics.getStatistics().incrementWordAmount(allWords.length);
        message.getSender().getStatistics().incrementWordAmount(allWords.length);

        // todo: check if there is better performance without applying the remove on the whole message
        // todo: (i.e., match directly on the members of allWords
        String cleanMessageNoStopWords;
        if (globalStatistics.getConversation().getLanguageProbability() > 0.5) {
            cleanMessageNoStopWords = this.stopWordsProvider.stopWordsPatternFor(globalStatistics.getConversation().getLanguage()).matcher(cleanMessage).replaceAll("");
        } else {
            cleanMessageNoStopWords = cleanMessage;
        }

        // reduce all instances of "laughter" like hahaha, ahahaha, etc. to haha
        cleanMessageNoStopWords = this.hahaPattern.matcher(cleanMessageNoStopWords).replaceAll("haha");

        String[] noStopWords = cleanMessageNoStopWords.split("\\s+");


        for (String token : noStopWords) {
            globalStatistics.getStatistics().incrementVocabulary(token.toLowerCase());
            message.getSender().getStatistics().incrementVocabulary(token.toLowerCase());
        }
    }
}
 
开发者ID:roberterdin,项目名称:thatsapp,代码行数:48,代码来源:StatisticsWorker.java

示例2: removeEmojis

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public static String removeEmojis(final String s) {
    return EmojiParser.removeAllEmojis(s);
}
 
开发者ID:TweetWallFX,项目名称:TweetwallFX,代码行数:4,代码来源:StopList.java


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