harper icon indicating copy to clipboard operation
harper copied to clipboard

Incorrect suggestion to change "new" to "knew"

Open Andrew15-5 opened this issue 1 year ago • 5 comments

Description

In Markdown file, it detects "new" as "knew":

To learn some new tricks.
Let's build this new template function.
Move the function definition inside of that new file.

Is it only flagging a non-error or is a spurious fix also suggested? Suggested.

Resources

Screenshots

Image

Andrew15-5 avatar Jun 09 '25 05:06 Andrew15-5

There are also these, dunno if I need to report them too:

The report got a straight A and a praise.

A dropdown menu.

<img
  src=""
  alt=""
  style="box-shadow: 0 4px 12px rgb(89 85 101 / 20%); width: 500px; max-width: 100%; display: block; margin: 24px auto;"
>

Image

Andrew15-5 avatar Jun 09 '25 05:06 Andrew15-5

There are also these, dunno if I need to report them too:

The report got a straight A and a praise.

A dropdown menu.

<img
  src=""
  alt=""
  style="box-shadow: 0 4px 12px rgb(89 85 101 / 20%); width: 500px; max-width: 100%; display: block; margin: 24px auto;"
>

Image

I have a feeling I've seen an issue filed against HTML being linted inside Markdown files but I can't seem to find it...

hippietrail avatar Jun 09 '25 07:06 hippietrail

I tried taking a crack at the new/knew issue with limited success. I think properly handling "some" is tricky with the existing code, which I assume is due to "some" being able to function as either a determiner or a pronoun depending on context. (Though afaik, currently it's never marked as a determiner.)

Maybe it's just my inexperience with writing linters (or my lack of grammar expertise), but trying to deal with "some" feels a bit like playing whack-a-mole. You fix one thing, you break another.

I currently have a hacky "fix" that properly lints (or doesn't):

  • "To learn some new tricks."
  • "She new danger lurked nearby."
  • "Though some new that was the case."
  • And all existing tests...

But it has a false positive on:

  • "Some new tricks were being developed." (I think both new/knew would technically be correct here (at least with the context available), so ideally it shouldn't produce a lint.)

I could push and create a PR for this, but I'm wondering if it might be better to just wait for the Brill tagger or the like to get merged. If I understand its purpose correctly, it might help us determine what sense of "some" is being used, which could allow for a more proper solution than the one I have now. (One that doesn't involve hacky unintuitive patterns that don't really make sense but fix specific edge cases.)

Alternatively, we could also simply add "some" to the excluded pronoun list. That would fix the false positives, though at the expense of creating false negatives.

86xsk avatar Jun 12 '25 01:06 86xsk

Whack-a-mole will be a theme in writing linters due to the ambiguous nature of language. Specifically when trying to figure out if something is a mistake or not we have to figure out which POS a certain word in the context is, and we'll do that by looking at its context in turn, which could also contain words with multiple POS. My understanding is that this is exactly the kind of thing the Brill tagger targets.

I try not to do fixes that create known problems. If unavoidable due to limitations of the system or long chains of whack-a-mole I'd probably document such in a comment and now I'd also add an ignored test that should ideally pass but fails now due to the known limitation.

I'd say go ahead with your PR - it will be great to have more people making lints so we can all understand common patterns and current limitations etc.

hippietrail avatar Jun 12 '25 02:06 hippietrail

Also

Let's build this new template function.
Move the function definition inside of that new file.

Andrew15-5 avatar Jun 12 '25 05:06 Andrew15-5