Class: Uniword::Spellcheck::GrammarChecker
- Inherits:
-
Object
- Object
- Uniword::Spellcheck::GrammarChecker
- Defined in:
- lib/uniword/spellcheck/grammar_checker.rb
Overview
Simple rule-based grammar checker.
Responsibility: Detect common grammar issues in text using pattern-based rules (no external dependencies).
Follows the Open/Closed Principle: new rules can be added by creating new check methods and registering them in #rules.
Each rule returns an array of hashes with :message, :position, and :context keys.
Instance Method Summary collapse
-
#check(text) ⇒ Array<Hash>
Check text for grammar issues using all registered rules.
Instance Method Details
#check(text) ⇒ Array<Hash>
Check text for grammar issues using all registered rules.
25 26 27 28 29 |
# File 'lib/uniword/spellcheck/grammar_checker.rb', line 25 def check(text) return [] if text.nil? || text.strip.empty? rules.flat_map { |rule| rule.call(text) } end |