Class: JLDrill::Deinflection::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/jldrill/model/DeinflectionRules.rb

Overview

Represents a deinflection rule. It contains the string that will be found in the original text, the text that will be used to replace the original text, and an index into the reason array.

Constant Summary collapse

RULE_RE =
/^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original, replaceWith, reason) ⇒ Rule

Returns a new instance of Rule.



37
38
39
40
41
# File 'lib/jldrill/model/DeinflectionRules.rb', line 37

def initialize(original, replaceWith, reason)
    @original = original
    @replaceWith = replaceWith
    @reason = reason
end

Instance Attribute Details

#originalObject (readonly)

Returns the value of attribute original.



33
34
35
# File 'lib/jldrill/model/DeinflectionRules.rb', line 33

def original
  @original
end

#reasonObject (readonly)

Returns the value of attribute reason.



33
34
35
# File 'lib/jldrill/model/DeinflectionRules.rb', line 33

def reason
  @reason
end

#replaceWithObject (readonly)

Returns the value of attribute replaceWith.



33
34
35
# File 'lib/jldrill/model/DeinflectionRules.rb', line 33

def replaceWith
  @replaceWith
end

Class Method Details

.parse(string, reasons) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/jldrill/model/DeinflectionRules.rb', line 43

def Rule::parse(string, reasons)
    retVal = nil
    if RULE_RE.match(string)
        retVal = Rule.new($1, $2, reasons[$4.to_i])
    end
    return retVal
end

Instance Method Details

#to_sObject



51
52
53
# File 'lib/jldrill/model/DeinflectionRules.rb', line 51

def to_s
    @original + "\t" + @replaceWith + "\t" + reason
end