本文整理汇总了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());
}
}
}
示例2: removeEmojis
import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public static String removeEmojis(final String s) {
return EmojiParser.removeAllEmojis(s);
}