class->SUPER::new($properties);
}
sub new_from_json_response {
my $class = shift;
my ($decoded_resp) = @_;
my $obj = $class->SUPER::new_from_json_response($decoded_resp);
$obj->_entry->{actio
Node' :
'REST::Neo4p::Relationship';
for (@$decoded_resp) {
push @ret, $class->new_from_json_response($_);
}
return @ret;
}
# create_unique : route to correct method
sub create_unique {
(ref $e && $e->can("rethrow")) ? $e->rethrow : die $e;
}
return REST::Neo4p::Node->new_from_json_response($decoded_resp);
}
sub create_unique_relationship {
my $self = shift;
my ($key, $val
ocessed. If called in a non-void context, the result is processed (via ResultProcessors) into a
# json/Perl format suitable for parsing by REST::Neo4p
#
# data
sub available_actions {
my $self =
e REST::Neo4p::Constraint;
use base 'Exporter';
use REST::Neo4p;
use REST::Neo4p::Exceptions;
use JSON;
use Data::Dumper;
use Scalar::Util qw(looks_like_number);
use strict;
use warnings;
our @EXPOR
[@EXPORT],
all => [@EXPORT,@EXPORT_OK]
);
our $jobj = JSON->new->utf8;
$jobj->allow_blessed(1);
$jobj->convert_blessed(1);
my $regex_to_json = sub {
my $qr = shift;
local $Data::Dumper::Terse=1
.__PACKAGE__."\n");
}
sub TO_JSON {
no warnings qw(redefine);
my $self = shift;
my $store;
my $old = *Regexp::TO_JSON{CODE};
*Regexp::TO_JSON = $regex_to_json;
$store = $self->constraint
JSON;
use File::Temp;
use Carp qw(croak carp);
use strict;
use warnings;
our @ISA;
our $VERSION;
BEGIN {
$REST::Neo4p::Agent::VERSION = '0.4003';
}
our $AUTOLOAD;
our $JOB_CHUNK = 1024;
our $JSON
= JSON->new()->allow_nonref(1)->utf8;
our $RQ_RETRIES = 3;
our $RETRY_WAIT = 5;
sub new {
my $class = shift;
my %args = @_;
my $mod = delete $args{agent_module} || 'LWP::UserAgent';
die "No u
o4p/$VERSION");
$self->default_header( 'Accept' => 'application/json' );
$self->default_header( 'Content-Type' => 'application/json' );
$self->default_header( 'X-Stream' => 'true' );
$self->pr
int 'Failed to send message\n";
}
=head1 DESCRIPTION
This module currently uses the L<HTTPS JSON API|https://gw.cmtelecom.com/>.
=head1 METHODS
=head2 new
# Create new sender using this d
package SMS::API::CMTelecom;
use 5.006;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
=head1 NAME
SMS::API::CMTelecom - SMS API for cmtelecom.com
=head1 VERSION
Version 0.01
=cut
our
t-Type' => 'application/json'],
encode_json $payload,
);
my $res = $self->{_ua}->request( $req );
if ($res->code == 200) {
my $result = decode_json $res->content();
n {
messages => $result->{messages},
};
}
my $result = eval { decode_json $res->content() };
return $self->_set_error_message($result->{details}) if ref $result eq 'HA
package REST::Neo4p;
use Carp qw(croak carp);
use lib '../../lib';
use JSON;
use URI;
use URI::Escape;
use HTTP::Tiny;
use JSON::ize;
use Neo4j::Driver 0.1801;
use REST::Neo4p::Agent;
use REST::Neo4p
;
our $HANDLE = 0;
our $AGENT_MODULE = $ENV{REST_NEO4P_AGENT_MODULE} || 'LWP::UserAgent';
my $json = JSON->new->allow_nonref(1)->utf8;
$HANDLES[0]->{_q_endpoint} = 'cypher';
sub set_handle {
my $
nected\n") unless $neo4p->connected;
my $decoded_resp;
if ($value) {
$value = uri_escape($json->encode($value));
}
eval {
# following line should work, but doesn't yet (self-discovery iss
N = '0.4003';
}
sub new {
my $class = shift;
bless { _length => 0 }, $class;
}
sub new_from_json_response {
my $class = shift;
my ($decoded_resp) = @_;
return $class->new_from_driver_obj(@
if defined $r;
}
return $ret;
}
sub simple_from_json_response {
my $class = shift;
my ($decoded_resp) = @_;
return $class->new_from_json_response($decoded_resp)->as_simple;
}
sub nodes { @
:Neo4p::StreamException' => {
isa => 'REST::Neo4p::LocalException',
description => 'Neo4j JSON response parsing error',
fields => ['message']
},
'REST::Neo4p::ConstraintException' =>
package Speech::Recognition::Vosk::Recognizer;
use Speech::Recognition::Vosk;
use JSON 'decode_json';
use Moo 2;
use Filter::signatures;
use feature 'signatures';
no warnings 'experimental::signature
Returns a hashref containing the recognized text.
=cut
sub result( $self ) {
return decode_json( Speech::Recognition::Vosk::recognizer_result($self->_recognizer))
}
=head2 C<< ->partial_result
xt may change
when more data is collected.
=cut
sub partial_result( $self ) {
return decode_json( Speech::Recognition::Vosk::recognizer_partial_result($self->_recognizer))
}
=head2 C<< ->final_
;
use base 'REST::Neo4p::Entity';
use REST::Neo4p::Relationship;
use REST::Neo4p::Exceptions;
use JSON;
use Carp qw(croak carp);
use strict;
use warnings;
BEGIN {
$REST::Neo4p::Node::VERSION = '0.40
$@->rethrow : die $@;
}
return ref($decoded_resp) ?
REST::Neo4p::Relationship->new_from_json_response($decoded_resp) :
REST::Neo4p::Relationship->new_from_batch_response($decoded_resp);
}
}
for (@$decoded_resp) {
push @ret, ref($_) ?
REST::Neo4p::Relationship->new_from_json_response($_) :
REST::Neo4p::Relationship->new_from_batch_response($_);
}
return @ret;
}
s
rapper in
L<Speech::Recognition::Vosk::Recognizer>.
use Speech::Recognition::Vosk;
use JSON 'decode_json';
my $model = Speech::Recognition::Vosk::model_new("model-en");
my $recognizer = Spee
eech::Recognition::Vosk::recognizer_partial_result($recognizer);
}
my $info = decode_json($spoken);
if( $info->{text}) {
print $info->{text},"\n";
} else {
my $spoken = Speech::Recognition::Vosk::recognizer_final_result($recognizer);
my $info = decode_json($spoken);
print $info->{text},"\n";
=head1 FUNCTIONS
=cut
require XSLoader;
XSLoader::load(_
use v5.10;
package REST::Neo4p::Query;
use REST::Neo4p::Path;
use REST::Neo4p::Exceptions;
use JSON::XS;
use REST::Neo4p::ParseStream;
use HOP::Stream qw/drop/;
use Tie::IxHash;
use File::Temp qw(:see
;
my $cls = "REST::Neo4p::$type";
return $as_object ? $cls->new_from_json_response($_[0]) :
$cls->simple_from_json_response($_[0]);
};
for (ref($elt)) {
/Driver/ && do {
$elt =
w, $elt;
}
}
};
if (my $e = Exception::Class->caught()) {
if ($e =~ /j_parse|json/i) {
$e = REST::Neo4p::StreamException->new(message => $e);
$self->{_error} = $e;
$e->throw if
nstraint subclass objects directly
# - factory function create_constraint()
# - load from a file (JSON, XML)
require REST::Neo4p::Entity;
require REST::Neo4p::Node;
sub create_constraint {
my %par
hip type disallowed, ignoring...\n";
}
# serialize all constraints
open $f, ">my_constraints.json";
print $f serialize_constraints();
close $f;
# remove current constraints
while ( my ($tag
traint->drop;
}
# restore constraints
open $f, "my_constraints.json";
local $/ = undef;
$json = <$f>;
load_constraints($json);
=head1 DESCRIPTION
L<Neo4j|http://neo4j.org>, as a NoSQL databa
#$Id$
use v5.10.1;
package REST::Neo4p::Batch;
use REST::Neo4p::Exceptions;
use JSON::XS;
use REST::Neo4p::ParseStream;
use HOP::Stream qw/drop head/;
require REST::Neo4p;
use base qw(Exporter);
use
= $agent->execute_batch_chunk;
my $jsonr = JSON::XS->new->utf8;
my $buf;
$tmpfh->read($buf, $BUFSIZE);
$jsonr->incr_parse($buf);
my $res = j_parse($jsonr);
die "j_parse: expecting BATCH s
j) if $action eq 'keep_objs';
}
}
when ('PENDING') {
$tmpfh->read($buf,$BUFSIZE);
$jsonr->incr_parse($buf)
}
when (!defined) {
last;
}
default {
die "j_parse:
$j)];
}
else {
# problem
return;
}
}
# generic parse array stream
# return decoded json entities at the top level
# opening [ must be removed
# handle empty array too
sub j_parse_array
($j->incr_text =~ m/^\]}\],/) { # JSON::XS <=3.04 transaction kludge
$j->incr_text =~ s/(\])(}\],)//;
$done=1;
}
elsif ($elt eq 'transaction') { # JSON::XS 4.02 transaction kludge
$j->
it the L<Neo4j|http://neo4j.org>
server's chunked transfer encoding of its JSON REST responses. It is
based on the fast L<JSON::XS> incremental parser and
L<MJD|https://metacpan.org/author/MJD>'s L<Hi
use v5.10;
package REST::Neo4p::Entity;
use REST::Neo4p::Exceptions;
use Carp qw(croak carp);
use JSON;
use URI::Escape;
use strict;
use warnings;
# base class for nodes, relationships, indexes...
BE
from_json_response($decoded_resp) :
$class->new_from_batch_response($decoded_resp, @$url_components);
}
# TODO: refactor for when response is from Neo4j::Driver (a Result)
sub new_from_json_res
row("new_from_json_response() called with undef argument\n");
}
my $is_json = !(ref($decoded_resp) =~ /Neo4j::Driver/);
unless ($ENTITY_TABLE->{$entity_type}{_actions} || !$is_json) {
# capt
$self->end_node};
$ret->{$_} = $props->{$_} for keys %$props;
return $ret;
}
sub simple_from_json_response {
my $class = shift;
my ($decoded_resp) = @_;
my $ret;
for (ref $decoded_resp) {
te( $update,'Landlord',sub {
my ( $self ) = @_;
$self->Id or $self->Id( undef ); # force Id of null in JSON
return { $self->to_hash };
} );
}
1;
# vim: ts=4:sw=4:et
Media',sub {
my ( $self ) = @_;
$self->Id or $self->Id( undef ); # force null in JSON request
return { $self->to_hash };
} );
}
sub download {
my ( $self ) = @_;