Class: CFGHelper::CYK

Inherits:
Object
  • Object
show all
Defined in:
lib/cfg_helper/cyk.rb

Overview

Implemention of cyk algo.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word, custom_rule) ⇒ CYK



8
9
10
11
12
# File 'lib/cfg_helper/cyk.rb', line 8

def initialize(word, custom_rule)
  @word        = word
  @rules       = custom_rule.select { |_, val| val.is_a?(Array) }
  @helper_vars = @rules.values.flatten
end

Instance Attribute Details

#is_in_lObject (readonly)

Returns the value of attribute is_in_l.



6
7
8
# File 'lib/cfg_helper/cyk.rb', line 6

def is_in_l
  @is_in_l
end

#matrixObject (readonly)

Returns the value of attribute matrix.



6
7
8
# File 'lib/cfg_helper/cyk.rb', line 6

def matrix
  @matrix
end

Instance Method Details

#runObject



14
15
16
17
18
# File 'lib/cfg_helper/cyk.rb', line 14

def run
  _cyk_fill_diagonal
  _cyk_fill_matrix
  @is_in_l = _is_in_l?
end