Implementation:A616567126 GPT WEB JAVA BannedPromptUtils
Appearance
| 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\bword-boundary regex (case-insensitive)checkBanned(promptEn)— ThrowsEwith 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