module Gemmy::Patches::ArrayPatch::InstanceMethods::RunCommands

Public Instance Methods

run_commands() click to toggle source

Part of the Nlp API Example:

include Gemmy::Components::Nlp
parse_sentence("A sentence").run_commands

Under the hood, parse_sentence is creating procs in the db These are evaluated here

# File lib/gemmy/patches/array_patch.rb, line 54
def run_commands
  _eval_noun = Gemmy.patch("string/i/eval_noun")
                    .method(:_eval_noun)
  return self.flat_map do |cmds|
    cmds&.map do |cmd|
      eval(VerbLexicon.get cmd[:verb].to_sym).call(*(
        cmd[:nouns]&.map do |noun|
          _eval_noun.call(noun, self)
        end
      ).to_a.compact)
    end
  end.compact
end