Class: Kotoshu::Readers::CompoundPattern
- Inherits:
-
Object
- Object
- Kotoshu::Readers::CompoundPattern
- Defined in:
- lib/kotoshu/readers/aff_data.rb
Overview
Compound pattern for checking compound words.
Instance Attribute Summary collapse
-
#left ⇒ String
Left side pattern.
-
#left_flag ⇒ Object
readonly
Returns the value of attribute left_flag.
-
#left_no_affix ⇒ Object
readonly
Returns the value of attribute left_no_affix.
-
#left_stem ⇒ Object
readonly
Returns the value of attribute left_stem.
-
#replacement ⇒ String?
Optional replacement.
-
#right ⇒ String
Right side pattern.
-
#right_flag ⇒ Object
readonly
Returns the value of attribute right_flag.
-
#right_no_affix ⇒ Object
readonly
Returns the value of attribute right_no_affix.
-
#right_stem ⇒ Object
readonly
Returns the value of attribute right_stem.
Instance Method Summary collapse
-
#initialize(left, right, replacement = nil) ⇒ CompoundPattern
constructor
Create a new compound pattern.
-
#match?(left_part, right_part) ⇒ Boolean
Check if this pattern matches the given left and right parts.
Constructor Details
#initialize(left, right, replacement = nil) ⇒ CompoundPattern
Create a new compound pattern.
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/kotoshu/readers/aff_data.rb', line 250 def initialize(left, right, replacement = nil) @left = left @right = right @replacement = replacement # Parse left side @left_stem, _, @left_flag = left.partition('/') @left_stem = '' if @left_stem == '0' @left_no_affix = @left_stem.empty? && left.start_with?('0') # Parse right side @right_stem, _, @right_flag = right.partition('/') @right_stem = '' if @right_stem == '0' @right_no_affix = @right_stem.empty? && right.start_with?('0') end |
Instance Attribute Details
#left ⇒ String
Left side pattern
241 242 243 |
# File 'lib/kotoshu/readers/aff_data.rb', line 241 def left @left end |
#left_flag ⇒ Object (readonly)
Returns the value of attribute left_flag.
242 243 244 |
# File 'lib/kotoshu/readers/aff_data.rb', line 242 def left_flag @left_flag end |
#left_no_affix ⇒ Object (readonly)
Returns the value of attribute left_no_affix.
242 243 244 |
# File 'lib/kotoshu/readers/aff_data.rb', line 242 def left_no_affix @left_no_affix end |
#left_stem ⇒ Object (readonly)
Returns the value of attribute left_stem.
242 243 244 |
# File 'lib/kotoshu/readers/aff_data.rb', line 242 def left_stem @left_stem end |
#replacement ⇒ String?
Optional replacement
241 242 243 |
# File 'lib/kotoshu/readers/aff_data.rb', line 241 def replacement @replacement end |
#right ⇒ String
Right side pattern
241 242 243 |
# File 'lib/kotoshu/readers/aff_data.rb', line 241 def right @right end |
#right_flag ⇒ Object (readonly)
Returns the value of attribute right_flag.
242 243 244 |
# File 'lib/kotoshu/readers/aff_data.rb', line 242 def right_flag @right_flag end |
#right_no_affix ⇒ Object (readonly)
Returns the value of attribute right_no_affix.
242 243 244 |
# File 'lib/kotoshu/readers/aff_data.rb', line 242 def right_no_affix @right_no_affix end |
#right_stem ⇒ Object (readonly)
Returns the value of attribute right_stem.
242 243 244 |
# File 'lib/kotoshu/readers/aff_data.rb', line 242 def right_stem @right_stem end |
Instance Method Details
#match?(left_part, right_part) ⇒ Boolean
Check if this pattern matches the given left and right parts.
271 272 273 274 275 276 277 278 279 280 |
# File 'lib/kotoshu/readers/aff_data.rb', line 271 def match?(left_part, right_part) return false unless left_part.stem.end_with?(@left_stem) return false unless right_part.stem.start_with?(@right_stem) return false if @left_no_affix && left_part.is_base? return false if @right_no_affix && right_part.is_base? return false if @left_flag && !left_part.flags.include?(@left_flag) return false if @right_flag && !right_part.flags.include?(@right_flag) true end |