|
NAMEPOE::Component::Hailo - A non-blocking wrapper around HailoSYNOPSISuse strict; use warnings; use POE qw(Component::Hailo); POE::Session->create( package_states => [ (__PACKAGE__) => [ qw(_start hailo_learned hailo_replied) ], ], ); POE::Kernel->run; sub _start { POE::Component::Hailo->spawn( alias => 'hailo', Hailo_args => { storage_class => 'SQLite', brain_resource => 'hailo.sqlite', }, ); POE::Kernel->post(hailo => learn => ['This is a sentence'], ); } sub hailo_learned { POE::Kernel->post(hailo => reply => ['This']); } sub hailo_replied { my $reply = $_[ARG0]->[0]; die "Didn't get a reply" if !defined $reply; print "Got reply: $reply\n"; POE::Kernel->post(hailo => 'shutdown'); } DESCRIPTIONPOE::Component::Hailo is a POE component that provides a non-blocking wrapper around Hailo. It accepts the events listed under "INPUT" and emits the events listed under "OUTPUT".METHODS"spawn"This is the constructor. It takes the following arguments:'alias', an optional alias for the component's session. 'Hailo_args', a hash reference of arguments to pass to Hailo's constructor. 'options', a hash reference of options to pass to POE::Session's constructor. "session_id"Takes no arguments. Returns the POE Session ID of the component.INPUTThis component reacts to the following POE events:"learn""train""reply""learn_reply""stats""save"All these events take two arguments. The first is an array reference of arguments which will be passed to the Hailo method of the same name. The second (optional) is a hash reference. You'll get this hash reference back with the corresponding event listed under "OUTPUT"."shutdown"Takes no arguments. Terminates the component.OUTPUTThe component will post the following event to your session:"hailo_learned""hailo_trained""hailo_replied""hailo_learn_replied""hailo_stats""hailo_saved""ARG0" is an array reference of arguments returned by the underlying Hailo method. "ARG1" is the context hashref you provided (if any).AUTHORHinrik Örn Sigurðsson, hinrik.sig@gmail.comLICENSE AND COPYRIGHTCopyright 2010 Hinrik Örn SigurðssonThis program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |