π Contributing Grammar Rules
We want to build the most comprehensive open-source library of grammar and style rules. This guide explains how you can contribute new rules to OpenGrammar.
How Rules Work
OpenGrammar uses a "Rule-Based Engine" for fast, offline analysis. These rules are defined using Regular Expressions (RegEx).
The rules are located in: opengrammar/backend/src/analyzer-simple.ts
Structure of a Rule
Each rule consists of:
- Pattern: A RegEx to find the issue.
- Suggestion: The text that should replace the error.
- Reason: An explanation of why this is an error.
Example: Common Misspelling
{
pattern: /\bteh\b/gi,
suggestion: 'the',
reason: 'Misspelled word. The correct spelling is "the".'
}
How to Contribute a Rule
You don't need to be an expert developer to contribute!
Option 1: Open an Issue (Non-Developers)
If you know a common mistake but don't want to touch the code:
- Go to the Issues tab.
- Choose the "Grammar Rule Suggestion" template.
- Provide the incorrect text, the correction, and the reason.
Option 2: Submit a Pull Request (Developers)
- Open
opengrammar/backend/src/analyzer-simple.ts. - Find the relevant category (e.g.,
checkBasicGrammar,checkCommonMisspellings). - Add your rule to the array.
- Run
bun x tscto ensure no syntax errors. - Submit your PR!
Categories of Rules Needed
We are looking for rules in the following categories:
1. Common Misspellings
Words that are frequently typed incorrectly (e.g., "recieve" β "receive").
2. Confused Words
Words that sound similar but have different meanings (e.g., "affect" vs "effect").
3. Redundant Phrases
Wordy phrases that can be simplified (e.g., "at this point in time" β "now").
4. Style & Clarity
Rules that help make writing more professional (e.g., avoiding excessive use of "very").
5. Punctuation & Spacing
Common errors with commas, apostrophes, and double spaces.
Thank you for helping us make OpenGrammar better for everyone!