package cn.com.tenlion.configcontent.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 关键词词检查
 * 2020年5月25日16:27:51
 * 崔宝铖
 */
public class AntistopCheck {

    /**
     * 需要监测是否包含敏感内容的字符串
     */
    private String sourceContent = "";

    /**
     * 字符串中包含的表情
     */
    private static List<String> emojiList = new ArrayList<String>();

    /**
     * 出现敏感词的数量
     */
    private Integer antistopCount = 0;

    /**
     * 对敏感词进行包装后的字符串
     */
    private String antistopContent = "";

    public AntistopCheck(String sourceContent){
        this.sourceContent = sourceContent;
        String antistopContent = AntistopUtil.buiderView(sourceContent);
        this.antistopContent = antistopContent;
        this.antistopCount = AntistopUtil.getCount(antistopContent);
    }

    public static void main(String[] args) {
        String zhang = "\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00习近平的内容\uD83D\uDE37哈哈";
        // 评论内容敏感词识别
        String viewContent = AntistopUtil.buiderView(zhang);
        // 敏感词触发次数
        int count = AntistopUtil.getCount(viewContent);
        System.out.println(count);


       /* char[] arr  = zhang.toCharArray();

        Pattern emoji1 = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]",
                Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
        Pattern emoji2 = Pattern.compile("[\u2600-\u27ff]",
                Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
        for (int i = 0 ; i < arr.length ; i++) {
            String emoji = arr[i] + "";
            Matcher emojiMatcher2 = emoji2.matcher(emoji);
            if (emojiMatcher2.find()) {
                emojiList.add(emoji);
                arr[i] = '*';
                continue;
            }
            Matcher emojiMatcher1 = emoji1.matcher(emoji);
            if (emojiMatcher1.find()) {
                emojiList.add(emoji + arr[i+1]);
                arr[i] = '*';
                arr[++i] = '*';
                continue;
            }
        }*/

    }

}
