package com.unis.sensitiveWord;

import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import com.github.houbb.sensitive.word.support.result.WordResultHandlers;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

/**
 * 敏感词测试
 * @program: snowy
 * @Date: 2024-05-17 14:51
 * @Author: TangSong
 * @Description:
 */
public class SensitiveWordTest {
    @Resource
    private SensitiveWordBs sensitiveWordBs;



    @Test
    public  void testWord() {
        sensitiveWordBs.init();
        String text = "五星红旗迎风飘扬，毛主席的画像屹立在天安门前。";
        System.out.println(sensitiveWordBs.contains(text));

        System.out.println(sensitiveWordBs.replace(text));

        System.out.println(sensitiveWordBs.findFirst(text));
        System.out.println(sensitiveWordBs.findFirst(text, WordResultHandlers.word()));
        System.out.println(sensitiveWordBs.findFirst(text, WordResultHandlers.raw()));

        System.out.println(sensitiveWordBs.findAll(text));
        System.out.println(sensitiveWordBs.findAll(text, WordResultHandlers.word()));
        System.out.println(sensitiveWordBs.findAll(text, WordResultHandlers.raw()));

    }

}
