Class PatternBasedModerator.Builder
java.lang.Object
com.tnsai.quality.security.moderation.PatternBasedModerator.Builder
- Enclosing class:
PatternBasedModerator
Builder for PatternBasedModerator.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPattern(ModerationResult.Category category, String regex, double score) Adds a custom pattern.blockThreshold(double threshold) Sets the block threshold.build()Builds the moderator.checkPII(boolean checkPII) Enables or disables PII checking.enabledCategories(Set<ModerationResult.Category> categories) Sets which categories to enable.warnThreshold(double threshold) Sets the warn threshold.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
addPattern
public PatternBasedModerator.Builder addPattern(ModerationResult.Category category, String regex, double score) Adds a custom pattern.- Parameters:
category- category to assignregex- regex patternscore- confidence score- Returns:
- this builder
-
blockThreshold
Sets the block threshold.- Parameters:
threshold- score threshold for blocking- Returns:
- this builder
-
warnThreshold
Sets the warn threshold.- Parameters:
threshold- score threshold for warnings- Returns:
- this builder
-
checkPII
Enables or disables PII checking.- Parameters:
checkPII- whether to check for PII- Returns:
- this builder
-
enabledCategories
Sets which categories to enable.- Parameters:
categories- enabled categories- Returns:
- this builder
-
build
Builds the moderator.- Returns:
- configured moderator
-