Class: UEAStemmer::Rule
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#rule_num ⇒ Object
readonly
Returns the value of attribute rule_num.
-
#suffix_size ⇒ Object
readonly
Returns the value of attribute suffix_size.
Instance Method Summary collapse
- #handle(word) ⇒ Object
-
#initialize(pattern, suffix_size, rule_num) ⇒ Rule
constructor
A new instance of Rule.
- #to_s ⇒ Object
Methods included from StringHelpers
Constructor Details
#initialize(pattern, suffix_size, rule_num) ⇒ Rule
Returns a new instance of Rule.
29 30 31 32 33 |
# File 'lib/rule.rb', line 29 def initialize(pattern, suffix_size, rule_num) @pattern = pattern.dup.freeze @suffix_size = suffix_size @rule_num = rule_num end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
27 28 29 |
# File 'lib/rule.rb', line 27 def pattern @pattern end |
#rule_num ⇒ Object (readonly)
Returns the value of attribute rule_num.
27 28 29 |
# File 'lib/rule.rb', line 27 def rule_num @rule_num end |
#suffix_size ⇒ Object (readonly)
Returns the value of attribute suffix_size.
27 28 29 |
# File 'lib/rule.rb', line 27 def suffix_size @suffix_size end |
Instance Method Details
#handle(word) ⇒ Object
35 36 37 |
# File 'lib/rule.rb', line 35 def handle(word) [remove_suffix(word, @suffix_size), @rule_num, self] if word =~ @pattern end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/rule.rb', line 39 def to_s "rule ##{@rule_num} (remove #{@suffix_size} letters from the end of the word when it matches pattern #{@pattern})" end |