Class: ChatCorrect::Contraction
- Inherits:
-
Object
- Object
- ChatCorrect::Contraction
- Defined in:
- lib/chat_correct/contraction.rb
Constant Summary collapse
- NOT_CONTRACTION =
{ 'am' => "ain't", 'do' => "don't", 'will' => "won't", 'shall' => "shan't", 'is' => "isn't" }
- IRREGULAR_CONTRACTION =
{ ['is', 'not'] => "ain't", ['madam', nil] => "ma'am", ['never-do-well', nil] => "ne'er-do-well", ['cat-of-nine-tails', nil] => "cat-o'-nine-tails", ['jack-of-the-lantern', nil] => "jack-o'-lantern", ['will-of-the-wisp', nil] => "will-o'-the-wisp" }
Instance Attribute Summary collapse
-
#contraction ⇒ Object
readonly
Returns the value of attribute contraction.
-
#token_a ⇒ Object
readonly
Returns the value of attribute token_a.
-
#token_b ⇒ Object
readonly
Returns the value of attribute token_b.
Instance Method Summary collapse
- #contraction? ⇒ Boolean
-
#initialize(token_a:, token_b:, contraction:) ⇒ Contraction
constructor
A new instance of Contraction.
Constructor Details
#initialize(token_a:, token_b:, contraction:) ⇒ Contraction
Returns a new instance of Contraction.
19 20 21 22 23 24 |
# File 'lib/chat_correct/contraction.rb', line 19 def initialize(token_a:, token_b:, contraction:) return false if token_a.nil? || contraction.nil? @token_a = token_a.downcase token_b ? @token_b = token_b.downcase : @token_b = token_b @contraction = contraction.downcase.gsub(/ƪ/, "'") end |
Instance Attribute Details
#contraction ⇒ Object (readonly)
Returns the value of attribute contraction.
18 19 20 |
# File 'lib/chat_correct/contraction.rb', line 18 def contraction @contraction end |
#token_a ⇒ Object (readonly)
Returns the value of attribute token_a.
18 19 20 |
# File 'lib/chat_correct/contraction.rb', line 18 def token_a @token_a end |
#token_b ⇒ Object (readonly)
Returns the value of attribute token_b.
18 19 20 |
# File 'lib/chat_correct/contraction.rb', line 18 def token_b @token_b end |
Instance Method Details
#contraction? ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chat_correct/contraction.rb', line 26 def contraction? !token_a.nil? && !contraction.nil? && (is_a_not_contraction? || is_an_irregular_contraction? || is_an_us_contraction? || is_an_am_contraction? || is_an_are_contraction? || is_an_is_does_has_contraction? || is_a_have_contraction? || is_a_had_did_would_contraction? || is_a_will_contraction? || is_an_of_contraction? || is_an_it_contraction? || is_a_them_contraction?) end |