Sub topic 12
Keyword filters and automation, and their false positives
This chapter assumes you already know the triage categories (spam, abuse, criticism, question, threat, legal claim) and the five actions (reply, hide, delete, block, escalate). It also assumes you have admin access to a brand account on at least one platform. Automation does not replace those decisions. It applies them faster, and it makes mistakes at the same speed.
What automation can and cannot do
Automation in comment moderation comes in three layers:
- Platform-native filters. Most platforms let you hide comments that contain listed words, comments with links, or comments that match a built-in "offensive" setting. Names and options differ, so check each platform's current settings.
- Third-party moderation tools. These sit on top of several accounts. They add rules, queues, tagging and assignment.
- Custom scripts. A small program reads comments through a platform's API and suggests an action.
All three are pattern matchers. They see characters, not intent. A filter cannot tell a customer quoting an insult from a customer using it. This gap produces the two errors you must manage.
| Error | What happens | Typical cost |
|---|---|---|
| False positive | A harmless comment is hidden or flagged | Legitimate customers are silenced, and complaints get hidden, which looks like censorship |
| False negative | A harmful comment is not caught | Spam, abuse or a threat stays visible, or an escalation is missed |
Tightening a filter lowers false negatives and raises false positives. Loosening it does the opposite. You cannot remove both, so you choose which error is cheaper for each category.
Choosing a threshold per category
The cost of each error differs by category, so the rules should differ too.
- Spam. A false positive costs little, since a real customer rarely writes "free followers". Filter aggressively.
- Abuse. Moderate risk. Words like "scum" can appear in a quote or a product name. Hide for human review rather than delete.
- Threats, legal and safety claims. A false negative is the expensive error. Here the filter should over-flag, and its output should be a flag for a human, never a silent hide.
- Complaints and questions. Never auto-hide. Hiding a complaint is the error most likely to damage trust. Automation may only tag these for a reply.
This is why the sample function below checks the most serious category first, and why it returns a suggestion.
A simple rules-based triage
The following script shows the idea. It returns an action and a reason, so a moderator can review the suggestion before anything happens.
import re
SPAM_RE = re.compile(r"free followers|crypto giveaway|dm me to earn", re.IGNORECASE)
ABUSE_TERMS = {"idiot", "scum"}
ESCALATE_TERMS = {"lawyer", "lawsuit", "injured", "hurt myself", "i will find you"}
COMPLAINT_TERMS = {"refund", "broken", "late", "not working", "disappointed"}
def triage(text: str, prior_strikes: int = 0) -> tuple[str, str]:
"""Return (action, reason) for one comment."""
lowered = text.lower()
if any(term in lowered for term in ESCALATE_TERMS):
return "escalate", "possible threat, safety or legal claim"
if SPAM_RE.search(text):
if prior_strikes >= 2:
return "block", "repeat spam"
return "hide", "spam"
if any(term in lowered for term in ABUSE_TERMS):
if prior_strikes >= 2:
return "block", "repeat abuse"
return "hide", "abusive language"
if "?" in text or any(term in lowered for term in COMPLAINT_TERMS):
return "reply", "question or complaint"
return "leave", "no action needed"
print(triage("My order is late, can I get a refund?"))
print(triage("Free followers! DM me to earn", prior_strikes=2))
print(triage("I am talking to my lawyer about this"))Running it prints:
('reply', 'question or complaint')
('block', 'repeat spam')
('escalate', 'possible threat, safety or legal claim')Three design choices matter here:
- Order encodes risk. The escalation check runs first, so a comment that is both abusive and a legal claim goes to the right owner instead of being hidden.
- Strikes change the action. The same spam is hidden the first time and leads to a block after repeated offenses. The script does not know whether
prior_strikesis accurate. That number must come from your audit log. - Output is a suggestion. The function takes no action itself.
Where this script produces false positives
The script is deliberately small, and it fails in predictable ways. Knowing them helps you design better rules.
| Input | Result | Problem |
|---|---|---|
| "Delivery was not late at all, thanks!" | reply | Praise is treated as a complaint because "late" matched |
| "Great glass, my lawyer friend loves it" | escalate | A harmless mention of "lawyer" triggers escalation |
| "Is the Scumble Cleaner safe for tiles?" | hide | The substring "scum" matches inside a product name, and a real question is hidden |
| "I'm injured by how good this is" | escalate | Figurative language |
| "fr33 f0llowers" | leave | Spelling tricks defeat the pattern, which is a false negative |
The third row comes from substring matching. "scum" in lowered matches inside longer words. One fix is word-boundary matching:
import re
ABUSE_RE = re.compile(r"\b(idiot|scum)\b", re.IGNORECASE)
print(bool(ABUSE_RE.search("Is the Scumble Cleaner safe for tiles?")))
print(bool(ABUSE_RE.search("You are scum")))This prints False and then True. The \b markers require the term to stand as a whole word. Word boundaries fix one class of error but add a new miss: "scumbag" is no longer caught unless you list it. Every fix trades one error for another.
Rules that hold up in practice
- Start in suggest mode. Run a new rule so it only tags or queues comments for two weeks. Count how often a human disagrees before you let it hide anything.
- Prefer hiding over deleting. Use hide as the strongest automatic action.
- Keep escalation rules broad and human-reviewed. A flagged "lawyer" comment costs a minute of review. A missed legal claim can cost far more.
- Never auto-hide complaints. Tag them for a reply instead.
- Maintain an allowlist. Product names, campaign hashtags and known partners should be exempt from rules that would match them.
- Treat links, mass mentions and repeated identical text as spam signals. These are often more reliable than words.
- Log automated actions as automated. Your audit log should record the rule that fired, so you can trace a bad outcome back to its rule.
Handling evasion and drift
People work around filters. They swap letters for numbers, add spaces, use emoji or write in another language. A static word list slowly loses accuracy. Normalizing text before matching (lowercasing, removing repeated characters, mapping common substitutions) helps, but it also raises false positives, so test every change on a sample.
Language is a particular risk. A filter built from English words may miss other languages you receive comments in, and it may flag words that are harmless in another language. If your audience is multilingual, review the filters with a speaker of each language.
Slang and reclaimed terms also shift. A word that was abusive last year may be casual now. Review the list on a schedule instead of only adding to it.
Measuring a filter
You can measure a rule with a small hand-labelled sample. Take 100 recent comments, label each by hand, run the rule, and compare.
- Precision: of the comments the rule flagged, how many were correctly flagged. Low precision means many false positives.
- Recall: of the comments that should have been flagged, how many the rule caught. Low recall means many false negatives.
Sample enough comments from each category. Threats are rare, so a random sample may contain none, and a rule that never flags a threat will still look accurate overall. Judge the escalation rules on recall, and judge spam rules mostly on precision.
Reviewing false positives
Automation needs a feedback loop. Once a week, a moderator should open the list of comments the filters hid and check whether any should be restored. Track three things: how many were restored, which rule caused them, and which words appear most often. A rule with many restorations should be narrowed or removed. This review feeds the metrics chapter later in this tutorial.
Also give users a way back. If someone says their comment vanished, a moderator should be able to find it, check the rule that hid it, and restore it. Quiet hiding of legitimate comments is a common reason audiences accuse brands of censorship.
Exercise
A rule hides any comment containing the word "late". A customer writes "My parcel is late and I want a refund." What goes wrong, and what should the rule do instead?
Show answer
The comment is a complaint, so hiding it is a false positive with a high trust cost. It also silences a customer who needs a reply. "Late" should not be a hide trigger. The rule should tag the comment as a complaint and queue it for a public reply or a move to private support. Hide rules should be reserved for categories such as spam where a false positive is cheap.
Exercise
Your escalation filter flags about 30 comments a week, and moderators find that 27 are harmless mentions of "lawyer" or "injured". Should you narrow the rule? Explain your reasoning.
Show answer
Not by much. Low precision here costs a few minutes of review per week, while a missed legal or safety claim is expensive, so recall matters more. Keep the broad rule, but reduce the review burden with small steps, such as adding context phrases ("my lawyer", "injured by your product") or an allowlist for common harmless uses. Check each change on a labelled sample to confirm that real cases still get flagged.