public int keyWordsFind(String content) { List<String> list = null; list = redisTemplate.opsForList().range("words_filter", 0, -1); if (CollectionUtils.isEmpty(list)) { try { org.springframework.core.io.Resource resource = new ClassPathResource("data/words.txt"); InputStream is = resource.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String data = null; while ((data = br.readLine()) != null) { if (StringUtils.isNotEmpty(data)) { list.add(data); } } br.close(); isr.close(); is.close(); redisTemplate.opsForList().rightPushAll("words_filter", list); } catch (Exception e) { e.printStackTrace(); } } WordTree tree =
java使用hutool的dfa过滤敏感词
最新推荐文章于 2024-05-02 08:00:00 发布