Module: Gemmy::Patches::ArrayPatch::InstanceMethods::RunCommands

Defined in:
lib/gemmy/patches/array_patch.rb

Instance Method Summary collapse

Instance Method Details

#run_commandsObject

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



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/gemmy/patches/array_patch.rb', line 67

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