Skip to content

fix(core): don't flag MissingTo after a possessive nominal - #4089

Open
mauropereiira wants to merge 1 commit into
Automattic:masterfrom
mauropereiira:fix/missing-to-possessive-noun
Open

fix(core): don't flag MissingTo after a possessive nominal#4089
mauropereiira wants to merge 1 commit into
Automattic:masterfrom
mauropereiira:fix/missing-to-possessive-noun

Conversation

@mauropereiira

Copy link
Copy Markdown
Contributor

Issues

Fixes #3951

Description

MissingTo flagged "This Article's aims are both theoretical and historical.", wanting an infinitive after "aims".

The cause is a chain of defaults rather than one bug:

  • "aims" is in the controller list.
  • Its dictionary entry supports both noun and verb readings.
  • The tagger defaults the ambiguous token to UPOS::VERB.
  • "are" carries verb metadata without explicit verb-form flags, so the lemma check passes.

So the pattern accepts "aims are", and nothing in the rule looked left. As the reporter put it, the rule pattern-matches the token without resolving its part of speech from the frame it sits in: X's aims are, not X aims to.

The guard is structural. A noun-capable controller immediately preceded by a possessive nominal is the head of a noun phrase, not a predicate missing an infinitive:

if controller.kind.is_noun()
    && preceded_by_word(context, |tok| tok.kind.is_possessive_nominal())
{
    return None;
}

This covers possessive nouns like "Article's" as well as possessive determiners, without keying on any specific word.

I also considered guarding on the following token being a finite verb, and rejected it: Harper cannot generally separate a finite base form from an infinitive using UPOS alone, so it would have suppressed legitimate missing-to cases before infinitive auxiliaries such as "be".

Demo

This Article's aims are both theoretical and historical.   clean     (was MissingTo)

She wants finish early.                                    flagged   (unchanged)
We need talk about pricing.                                flagged   (unchanged)

How Has This Been Tested?

cargo test -p harper-core

test result: ok. 6130 passed; 0 failed; 290 ignored; 0 measured; 0 filtered out

Each existing positive in missing_to.rs was checked against the guard; none has a preceding possessive nominal, so all remain eligible. No files under harper-core/tests/text/ change.

AI Disclosure

  • I used an AI agent interactively.

If Your PR Implements or Enhances a Linter

  • I'm using examples from the bug report / feature request.

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.

`MissingTo` read "aims" in "This Article's aims are ..." as a verb wanting
an infinitive, because the token is noun/verb ambiguous and the tagger
defaults it to VERB. A controller preceded by a possessive is a noun in a
noun phrase, not a predicate.

Suppress noun-capable controllers immediately preceded by a possessive
nominal. The existing positives have no preceding possessive and are
unaffected.

Fixes Automattic#3951

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@hippietrail

Copy link
Copy Markdown
Collaborator

The cause is a chain of defaults rather than one bug:

  • "aims" is in the controller list.
  • Its dictionary entry supports both noun and verb readings.
  • The tagger defaults the ambiguous token to UPOS::VERB.

Oh this is the kind of thing that made me never comfortable with using UPOS. In the linters I write I always try to work out which POS is likely, or document when I can't. This is of course also not ideal.
I think at one point I wanted so sus out how it worked and it failed on the "the cat sat on the mat" test. I was also never sure whether it used the POSes from the dictionary or was completely external. I also never looked at its code to try to grok either its exact intent or logic.

But perhaps we should start a new issue specifically gathering places like this where it fails so that it can be improved at some point?

  • "are" carries verb metadata without explicit verb-form flags, so the lemma check passes.

Yes "is" is unique in that it has more forms than all other English verbs and its agreement rules are more involved. At some point we might want to have a good think about whether we want a special Be or ToBe module along the lines of IrregularVerbs or such as a centralized place for logic applying to it and its forms that can be used in any linter. Alternatively we could add methods on the low-level DictWordMetadata or higher level TokenKind modules to add new queryable properties that don't rely on annotation flags that would only be applies to a tiny handful of entries...

Apologies for not diving deep into the rest of this PR. Just adding some thoughts for now as there's a ton of new issues and PRs to look at...

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.

WordChoice rule (MissingTo) fires without part-of-speech context

2 participants