Class: Kotoshu::Readers::ConditionChecker Abstract
- Inherits:
-
Object
- Object
- Kotoshu::Readers::ConditionChecker
- Defined in:
- lib/kotoshu/readers/condition_checker.rb
Overview
This class is abstract.
Subclasses must implement the matches? method
Base class for checking affix conditions.
Hunspell affix rules specify conditions that the stem must match before an affix can be applied. Different scripts may have different interpretations of these conditions.
Conditions are anchored differently for prefixes vs suffixes:
- Suffix condition
ymatches stems that END withy(e.g.[^y]$) - Prefix condition
ijmatches stems that START withij(e.g.^ij)
Direct Known Subclasses
Class Method Summary collapse
-
.compile(condition, script: :latin, type: :suffix) ⇒ ConditionChecker
Compile a condition string into a checker.
Instance Method Summary collapse
-
#matches?(stem) ⇒ Boolean
Check if the given stem matches this condition.
Class Method Details
.compile(condition, script: :latin, type: :suffix) ⇒ ConditionChecker
Compile a condition string into a checker.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kotoshu/readers/condition_checker.rb', line 29 def self.compile(condition, script: :latin, type: :suffix) case script when :latin LatinScriptConditionChecker.compile(condition, type: type) else # For other scripts, create a passthrough checker # (condition is not applied) PassthroughConditionChecker.new end end |
Instance Method Details
#matches?(stem) ⇒ Boolean
Check if the given stem matches this condition.
44 45 46 |
# File 'lib/kotoshu/readers/condition_checker.rb', line 44 def matches?(stem) raise NotImplementedError, "#{self.class} must implement #matches?" end |