Method: MarkovTwitter::MarkovBuilder#_evaluate

Defined in:
lib/markov_twitter/markov_builder.rb

#_evaluate(length:, probability_bounds: [0,100], root_node: nil, direction:, node_finder:) ⇒ Array<Node>

An “evaluation” of the markov chain. e.g. a run case. Passes random values through the probability sequences.

Parameters:

  • length (Integer)

    the number of tokens in the result.

  • probability_bounds (Array<Integer, Integer>) (defaults to: [0,100])

    optional, can limit the probability to a range where 0 <= min <= result <= max <= 100.

  • node_finder (Lambda<Node>)

    during iteration, if the current node has no linkages in <direction>, a new node is selected from the nodes dict. The first randomly-picked node which this lambda returns a truthy value for is selected.

Returns:

  • (Array<Node>)

    the result tokens in order.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/markov_twitter/markov_builder.rb', line 168

def _evaluate(
  length:,
  probability_bounds: [0,100],
  root_node: nil,
  direction:,
  node_finder:
)
  length.times.reduce([]) do |result_nodes|
    root_node ||= get_new_start_point(node_finder)
    result_nodes.push root_node
    root_node = pick_linkage(
      root_node.linkages[direction],
      probability_bounds,
    )
    result_nodes
  end
end