Sub topic 12
Keyword Filters and Automation, and Their False Positives
Assume you already have a comment policy, basic platform moderation access, and categories for spam, abuse, criticism, questions, threats, and legal claims. This chapter focuses on using automation safely. Automation should reduce repetitive work, not make irreversible decisions without review.
What a filter does
A keyword filter watches incoming comments for words, phrases, links, or patterns. It can then flag, hide, delete, restrict, or route a comment. A rules-based system follows conditions that you define. For example, a rule might flag comments containing “free followers” or hide comments with a known slur.
Use filters for high-volume, predictable problems:
- Repeated spam phrases and promotional links
- Known abusive terms
- Personal information, such as phone-number patterns
- Comments that need a specialist’s attention
- Repeated content from previously actioned accounts
Do not treat a keyword match as proof of intent. A word can appear in a complaint, a question, or a harmless conversation.
| Filter result | Good default use | Main risk |
|---|---|---|
| Flag for review | Uncertain abuse or legal language | Review queue grows |
| Hide temporarily | Clear spam or harassment | Legitimate comments disappear |
| Delete automatically | Only narrowly defined, high-confidence spam | Evidence and context are lost |
| Escalate | Safety, legal, privacy, or threat indicators | Unnecessary pressure on specialists |
Build rules with review levels
Start with three levels:
- Observe: Record matches without changing visibility. Use this while testing.
- Suggest: Recommend an action for a moderator to approve.
- Act: Apply an automatic action only when the rule has a low false-positive rate.
A false positive occurs when a filter marks acceptable content as problematic. A false negative occurs when harmful content passes through. You need to measure both.
import re
RULES = [
("spam", re.compile(r"\bfree followers\b|\bcrypto giveaway\b", re.I)),
("possible_threat", re.compile(r"\bi will find you\b|\blawsuit\b", re.I)),
]
def suggest_action(comment: str) -> tuple[str, str]:
for category, pattern in RULES:
if pattern.search(comment):
if category == "spam":
return "hide_for_review", category
return "escalate", category
return "leave", "no_match"
for text in ["Free followers for your page", "I am speaking to my lawyer"]:
print(text, "->", suggest_action(text))The function checks serious categories first when they appear earlier in the rules. In production, keep the original comment, matched rule, timestamp, platform, and moderator decision in an audit log.
Test for false positives
Test rules against real, anonymized comments before activating them. Include:
- Complaints that quote the filtered phrase
- Questions using an abuse term descriptively
- Different spellings, punctuation, and languages
- Sarcasm and common misspellings
- Short comments with little context
Review samples regularly. If a rule hides too many useful comments, narrow the phrase, lower its action level, or require a second signal such as a suspicious link and repeated posting.
Common errors
- Using a single word as enough evidence
- Activating a rule without a test period
- Ignoring language, spelling, and cultural context
- Letting automation replace a clear owner and response time
- Failing to review whether rules still match current spam patterns
Exercise
A filter matches “lawsuit” in a customer’s comment. Should it delete the comment automatically?
Show answer
No. Flag or hide it according to policy, preserve the comment, and escalate it to the legal owner for review.