Skip to content

fix(core): do not flag Dickens as a swear - #4031

Open
mauropereiira wants to merge 2 commits into
Automattic:masterfrom
mauropereiira:fix/dickens-swear-metadata
Open

fix(core): do not flag Dickens as a swear#4031
mauropereiira wants to merge 2 commits into
Automattic:masterfrom
mauropereiira:fix/dickens-swear-metadata

Conversation

@mauropereiira

@mauropereiira mauropereiira commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

AI disclosure: An AI agent implemented and tested this patch with direction from Mauro Pereira.

Issues

Fixes #1656.

Description

The X suffix flag on both Dick and dick generated Dickens and dickens. Generated forms inherited metadata from their stems, so the lowercase path marked Dickens as a swear when dictionary entries were merged.

This removes the X flag from those stems and adds dickens explicitly. The existing Dickens entry remains the proper noun, the lowercase word remains accepted, and dick remains marked as a swear.

Demo

Before this change, Charles Dickens wrote many novels. triggered AvoidCurses. It now produces no lint. What the dickens is going on? also remains accepted.

How Has This Been Tested?

  • cargo test -p harper-core
  • cargo test -q
  • cargo run --bin harper-cli -- audit-dictionary harper-core
  • cargo fmt -- --check
  • cargo clippy -- -Dwarnings -D clippy::dbg_macro -D clippy::needless_raw_string_hashes
  • cargo hack check --each-feature
  • pnpm check
  • git diff --check
  • Manual CLI checks for both demo sentences
  • Two independent code reviews reported no findings

AI Disclosure

  • I am a human and did not use any AI.
  • I used LLM features of my editor, but not an agent.
  • I consulted one or more coding AIs, but did not use an agent.
  • I used an AI agent interactively.
  • I am an agent or I got an agent to do the work autonomously.

If Your PR Implements or Enhances a Linter

  • I made up the sentences in the unit tests.
  • The sentences in the unit tests were generated by an AI.
  • I am using examples from the bug report / feature request.
  • I collected real-world sentences for the unit tests.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have considered splitting this into smaller pull requests.

@hippietrail

Copy link
Copy Markdown
Collaborator

This looks like the right fix to me. Thanks.

@hippietrail hippietrail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're close. Let's make the dictionary entries nice and clean. Also this is still a draft - is that intentional?

Comment thread harper-core/dictionary.dict Outdated
dicier/Jc
diciest/Ju
dick/~NgSV>XZx
dick/~NgSV>Zx

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well remove > while we're at it. It generates dicker, which has its own entry anyway. So we should also remove x which apparently generates dickers if I'm not mistaken.
But then since the dicker entry doesn't generate a plural we should add /S to it.
I better look into "dicker" since I'm not sure I know it... OK so "dicker" is a verb so "dickered", "dickering", and "dickers" are all legit. Several dictionaries also list it as a noun, so let's go with

dick/~NgSVx
dicker/VdGS

Drop the `>` and `Z` agent-noun suffixes from `dick`. Both generated forms
that `dicker` already provides, and the `x` swear property propagates, so
they also marked `dicker` and `dickers` as swears.

Add `S` to `dicker` so it keeps generating a plural now that `Z` is gone.
Keep the existing `N`, since `S` targets `noun.is_plural` only when the base
carries noun metadata; without `N` the generated `dickers` would be a verb
form alone and the noun sense would be lost.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9k6gnF8CUtKAPo1LoLZyZ
@mauropereiira
mauropereiira marked this pull request as ready for review August 16, 2026 15:06
@mauropereiira

Copy link
Copy Markdown
Contributor Author

Draft was not intentional, sorry about that. Marked ready for review.

Cleaned up the entries as suggested. dick loses > and Z, which is a better fix than I had: since x propagates, those two suffixes were also marking dicker and dickers as swears, so this removes a second false positive I had not spotted.

I did deviate from your snippet on one character and want to flag it rather than slip it past you. You wrote:

dicker/VdGS

The current entry is dicker/VdGN, so that would drop the N. Going by your own note that several dictionaries list it as a noun, I do not think you meant to. It matters because S is conditional on the base:

"target": [
  { "if_base": { "noun": {} }, "metadata": { "noun": { "is_plural": true } } },
  { "if_base": { "verb": {} }, "metadata": { "verb": { "verb_form": "THIRD_PERSON_SINGULAR" } } }
]

Without N on the base, dickers would come out as a third person singular verb form only, and the plural noun sense would disappear. So I went with dicker/VdGNS. Happy to change it to exactly what you wrote if you did mean to drop the noun.

Final entries:

dick/~NgSVx
dickens/N
dicker/VdGNS

Checked the metadata after rebuilding:

word swear noun verb
dick true true true
dickens not set true false
Dickens not set true false
dicker not set true true
dickers not set true true
dickered not set false true
dickering not set true true

I also checked whether anything else in the dictionary has this shape. Four other entries combine x with a generating suffix: fuck, piss, shitty and wank. None of them has the same problem, because their generated forms are legitimately swears too, and none carries X, which was the suffix that produced dickens in the first place. So this stays a two-line change.

cargo test -p harper-core passes with 0 failures, and harper-cli audit-dictionary harper-core reports nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive: "Dickens" flagged as a swear

2 participants