errata-ai / Microsoft

A Vale-compatible implementation of the Microsoft Writing Style Guide.
https://github.com/errata-ai/vale
MIT License
85 stars 46 forks source link

Only correct "they are" if it isn't at the end of a sentence #40

Closed boardfish closed 2 years ago

boardfish commented 2 years ago

Thanks to @Spone for this.

In a sentence like "We appreciate all contributions, no matter how small they are.", Vale (backed by this repo) would suggest replacing they are with they're, resulting in the slightly awkward "no matter how small they're." This PR aims to fix that with a negative lookahead that ensures "they are" isn't followed by a period marking the end of the sentence.

Do we also want to include other symbols that can end sentences (? !) in the regex?

jdkato commented 2 years ago

Could you add a few tests to Contractions/test.md?

Essentially just sentences that should either pass or fail the rule.

boardfish commented 2 years ago

@jdkato I've added tests. There's a small catch - I was unable to get it to error if a sentence ends with a contraction.

I've also realized that most of the other mappings listed would probably have valid sentences that can trigger issues, so I'll work through those too.

boardfish commented 2 years ago

The tests marked with a TODO comment don't yet pass. I'll read around, but if there's anything anyone knows about how Vale handles regex that's stopping me from using those positive lookaheads, please let me know 🙏

jdkato commented 2 years ago

Everything looks okay on my end -- the TODOs are passing for me:

Screen Shot 2022-02-20 at 1 58 34 PM

So, I'm going to go ahead and merge this.

Thanks for your work here!