Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A616567126 GPT WEB JAVA BannedPromptUtils

From Leeroopedia
Knowledge Sources
Domains Content_Safety, Text_Processing
Last Updated 2026-10-13 00:00 GMT

Overview

Concrete tool for checking translated English prompts against a banned words list using word-boundary regex matching, provided as a utility class.

Description

The BannedPromptUtils class is a @UtilityClass that loads a list of banned words from banned-words.txt (external path or classpath resource) at class load time. It provides:

  • isBanned(promptEn) — Returns true if any banned word matches using \b word-boundary regex (case-insensitive)
  • checkBanned(promptEn) — Throws E with the matched banned word

Usage

Import this utility when you need to:

  • Filter Midjourney prompts after translation
  • Block prohibited content before task submission

Code Reference

Source Location

  • Repository: GPT-WEB-JAVA
  • File: src/main/java/com/intelligent/bot/utils/mj/BannedPromptUtils.java

Signature

@UtilityClass
public class BannedPromptUtils {
    public static boolean isBanned(String promptEn);
    public static void checkBanned(String promptEn);
}

Import

import com.intelligent.bot.utils.mj.BannedPromptUtils;

I/O Contract

Inputs

Name Type Required Description
promptEn String Yes English translated prompt

Outputs

Name Type Description
isBanned returns boolean true if any banned word found
checkBanned returns void Throws E with matched word

Usage Examples

Banned Word Check in MjController

String promptEn = translatePrompt(prompt);
if (BannedPromptUtils.isBanned(promptEn)) {
    throw new E("可能包含敏感词");
}

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment