view release on metacpan or search on metacpan
Matcher.cpp view on Meta::CPAN
}
// root's fail function is root
if (n == root) continue;
// Follow fail function from parent to find the longest suffix
// (or reach the root)
Trie *fail = n->parent->fail;
while (fail->get_child(n->label) == nullptr && fail != root) {
fail = fail->fail;
}
// We found the suffix...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/AhoCorasick/SearchMachine.pm view on Meta::CPAN
foreach my $p (@{$self->{keywords}}) {
my $nd = $self->{root};
foreach my $c (split //, $p) {
my $ndNew = $nd->get_transition($c);
if (!$ndNew) {
$ndNew = Algorithm::AhoCorasick::Node->new(parent => $nd, char => $c);
$nd->add_transition($ndNew);
}
$nd = $ndNew;
}
lib/Algorithm/AhoCorasick/SearchMachine.pm view on Meta::CPAN
while (@nodes) {
my @newNodes;
foreach my $nd (@nodes) {
my $r = $nd->parent->failure;
my $c = $nd->char;
while ($r && !($r->get_transition($c))) {
$r = $r->failure;
}
lib/Algorithm/AhoCorasick/SearchMachine.pm view on Meta::CPAN
my $class = shift;
my $self = { @_ };
$self->{results} = { };
$self->{transitions} = { };
weaken $self->{parent} if $self->{parent};
return bless $self, $class;
}
sub char {
my $self = shift;
lib/Algorithm/AhoCorasick/SearchMachine.pm view on Meta::CPAN
}
return $self->{char};
}
sub parent {
my $self = shift;
if (!exists($self->{parent})) {
die "root node has no parent";
}
return $self->{parent};
}
sub failure {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
op_integerize|||
op_linklist||5.013006|
op_lvalue_flags|||
op_lvalue||5.013007|
op_null||5.007002|
op_parent||5.021002|n
op_prepend_elem||5.013006|
op_refcnt_dec|||
op_refcnt_inc|||
op_refcnt_lock||5.009002|
op_refcnt_unlock||5.009002|
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Backoff/Constant.pm view on Meta::CPAN
package Algorithm::Backoff::Constant;
use strict;
use warnings;
use parent qw(Algorithm::Backoff);
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-02-24'; # DATE
our $DIST = 'Algorithm-Backoff'; # DIST
our $VERSION = '0.010'; # VERSION
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
my $method = $1;
if ( uc($method) eq $method ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/C3.pm view on Meta::CPAN
use Carp 'confess';
our $VERSION = '0.11';
sub merge {
my ($root, $parent_fetcher, $cache) = @_;
$cache ||= {};
my @STACK; # stack for simulating recursion
my $pfetcher_is_coderef = ref($parent_fetcher) eq 'CODE';
unless ($pfetcher_is_coderef or $root->can($parent_fetcher)) {
confess "Could not find method $parent_fetcher in $root";
}
my $current_root = $root;
my $current_parents = [ $root->$parent_fetcher ];
my $recurse_mergeout = [];
my $i = 0;
my %seen = ( $root => 1 );
my ($new_root, $mergeout, %tails);
while(1) {
if($i < @$current_parents) {
$new_root = $current_parents->[$i++];
if($seen{$new_root}) {
my @isastack;
my $reached;
for(my $i = 0; $i < $#STACK; $i += 4) {
if($reached || ($reached = ($STACK[$i] eq $new_root))) {
push(@isastack, $STACK[$i]);
}
}
my $isastack = join(q{ -> }, @isastack, $current_root, $new_root);
die "Infinite loop detected in parents of '$root': $isastack";
}
$seen{$new_root} = 1;
unless ($pfetcher_is_coderef or $new_root->can($parent_fetcher)) {
confess "Could not find method $parent_fetcher in $new_root";
}
push(@STACK, $current_root, $current_parents, $recurse_mergeout, $i);
$current_root = $new_root;
$current_parents = $cache->{pfetch}->{$current_root} ||= [ $current_root->$parent_fetcher ];
$recurse_mergeout = [];
$i = 0;
next;
}
lib/Algorithm/C3.pm view on Meta::CPAN
# that was a perl-port of the python code at
# http://www.python.org/2.3/mro.html :)
# Initial set (make sure everything is copied - it will be modded)
my @seqs = map { [@$_] } @$recurse_mergeout;
push(@seqs, [@$current_parents]) if @$current_parents;
# Construct the tail-checking hash (actually, it's cheaper and still
# correct to re-use it throughout this function)
foreach my $seq (@seqs) {
$tails{$seq->[$_]}++ for (1..$#$seq);
lib/Algorithm/C3.pm view on Meta::CPAN
return @$mergeout if !@STACK;
$i = pop(@STACK);
$recurse_mergeout = pop(@STACK);
$current_parents = pop(@STACK);
$current_root = pop(@STACK);
push(@$recurse_mergeout, $mergeout);
}
}
lib/Algorithm/C3.pm view on Meta::CPAN
=head1 FUNCTION
=over 4
=item B<merge ($root, $func_to_fetch_parent, $cache)>
This takes a C<$root> node, which can be anything really it
is up to you. Then it takes a C<$func_to_fetch_parent> which
can be either a CODE reference (see L<SYNOPSIS> above for an
example), or a string containing a method name to be called
on all the items being linearized. An example of how this
might look is below:
lib/Algorithm/C3.pm view on Meta::CPAN
our @ISA = ('B', 'C');
}
print join ", " => Algorithm::C3::merge('D', 'supers');
The purpose of C<$func_to_fetch_parent> is to provide a way
for C<merge> to extract the parents of C<$root>. This is
needed for C3 to be able to do it's work.
The C<$cache> parameter is an entirely optional performance
measure, and should not change behavior.
If supplied, it should be a hashref that merge can use as a
private cache between runs to speed things up. Generally
speaking, if you will be calling merge many times on related
things, and the parent fetching function will return constant
results given the same arguments during all of these calls,
you can and should reuse the same shared cache hash for all
of the calls. Example:
sub do_some_merging {
view all matches for this distribution
view release on metacpan or search on metacpan
t/test.data view on Meta::CPAN
of IN O
UAL NNP B
, , O
United NNP B
's POS B
parent NN I
company NN I
, , O
dived VBD O
$ $ B
24.875 CD I
t/test.data view on Meta::CPAN
to TO O
the DT B
Contras NNPS I
, , O
an DT B
apparent JJ I
attempt NN I
to TO O
curry VB O
more JJR B
favor NN I
t/test.data view on Meta::CPAN
NESB NNP B
is VBZ O
also RB O
the DT B
parent NN I
of IN O
Omnibank NNP B
. . O
Lung-cancer NN B
t/test.data view on Meta::CPAN
. . O
Currently RB O
, , O
its PRP$ B
parent NN I
company NN I
, , O
Hooker NNP B
Corp. NNP I
of IN O
t/test.data view on Meta::CPAN
suppliers NNS B
, , O
and CC O
Mr. NNP B
Merksamer NNP I
apparently RB O
wanted VBD O
assurances NNS B
that IN O
he PRP B
wo MD O
t/test.data view on Meta::CPAN
Continental NNP I
Corp. NNP I
, , O
Lincoln NNP B
's POS B
parent NN I
, , O
and CC O
who WP B
contributed VBD O
heavily RB O
t/test.data view on Meta::CPAN
shift VB O
insured VBN B
deposits NNS I
to TO O
the DT B
parent NN I
company NN I
, , O
which WDT B
used VBD O
the DT B
t/test.data view on Meta::CPAN
, , O
chairman NN B
of IN O
Eastern NNP B
's POS B
parent NN I
Texas NNP I
Air NNP I
Corp. NNP I
, , O
said VBD O
t/test.data view on Meta::CPAN
confidence NN I
. . O
In IN O
an DT B
apparent JJ I
attempt NN I
to TO O
keep VB O
a DT B
lid NN I
t/test.data view on Meta::CPAN
PNC NNP B
Financial NNP I
Corp. NNP I
, , O
the DT B
parent NN I
of IN O
Pittsburgh NNP B
National NNP I
Bank NNP I
, , O
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
unshift @_, ($self, $1);
goto &{$self->can('call')} unless uc($1) eq $1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Cluster/Thresh.pm view on Meta::CPAN
# print sprintf "%3d %3d %.3f\n", $i,$nodecluster[$i], $node->distance;
my $left = $node->left;
# Nodes are numbered -1,-2,... Leafs are numbered 0,1,2,...
my $leftref = $left < 0 ? \$nodecluster[-$left-1] : \$leafcluster[$left];
my $assigncluster = $nodecluster[$i];
# Left is always the same as the parent node's cluster
$$leftref = $assigncluster;
# print sprintf "\tleft %3d %3d\n", $left, $$leftref;
my $right = $node->right;
# Put right into a new cluster, when thresh not satisfied
if ($node->distance > $thresh) { $assigncluster = $icluster++ }
view all matches for this distribution
view release on metacpan or search on metacpan
src/cluster.c view on Meta::CPAN
int i = -nelements+1; /* top node */
int j;
int k = -1;
int previous = nelements;
const int n = nelements-nclusters; /* number of nodes to join */
int* parents;
if (nclusters == 1) {
for (i = 0; i < nelements; i++) clusterid[i] = 0;
return 1;
}
parents = malloc((nelements-1)*sizeof(int));
if (!parents) return 0;
while (1) {
if (i >= 0) {
clusterid[i] = k;
j = i;
i = previous;
src/cluster.c view on Meta::CPAN
i = tree[j].right;
if (j >= n && (i >= 0 || -i-1 < n)) k++;
}
else if (previous == tree[j].right) {
previous = i;
i = parents[j];
if (i == nelements) break;
}
else {
parents[j] = previous;
previous = i;
i = tree[j].left;
if (j >= n && (i >= 0 || -i-1 < n)) k++;
}
}
}
free(parents);
return 1;
}
/* ******************************************************************** */
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
unless ($$sym =~ s/([^:]+)$//) {
# XXX: it looks like we can't retrieve the missing function
# via $$sym (usually $main::AUTOLOAD) in this case.
view all matches for this distribution
view release on metacpan or search on metacpan
html/jquery.couponcode.js view on Meta::CPAN
}
var start_val = $(base_entry).val();
var name = base_entry.name;
var id = base_entry.id;
var wrapper = $( $(base_entry).wrap('<span class="jq-couponcode" />').parent()[0] );
wrapper[0].removeChild(base_entry);
var hidden = $('<input type="hidden">').attr({ 'name': name, 'id': id });
wrapper.append(hidden);
var inner = $('<span class="jq-couponcode-inner" />');
for(var i = 0; i < self.parts; i++) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
As the name implies, this is the method that construct a regression tree.
=item B<display_regression_tree(" "):>
Displays the regression tree, as the name implies. The white-space string argument
specifies the offset to use in displaying the child nodes in relation to a parent
node.
=item B<prediction_for_single_data_point( $root_node, $test_sample ):>
You call this method after you have constructed a regression tree if you want to
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
my $method = $1;
if ( uc($method) eq $method ) {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
my $method = $1;
if ( uc($method) eq $method ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Dependency/Ordered.pm view on Meta::CPAN
#pod Algorithm::Dependency::Ordered implements the most common variety of
#pod L<Algorithm::Dependency>, the one in which the dependencies of an item must
#pod be acted upon before the item itself can be acted upon.
#pod
#pod In use and semantics, this should be used in exactly the same way as for the
#pod main parent class. Please note that the output of the C<depends> method is
#pod NOT changed, as the order of the depends is not assumed to be important.
#pod Only the output of the C<schedule> method is modified to ensure the correct
#pod order.
#pod
#pod For API details, see L<Algorithm::Dependency>.
lib/Algorithm/Dependency/Ordered.pm view on Meta::CPAN
Algorithm::Dependency::Ordered implements the most common variety of
L<Algorithm::Dependency>, the one in which the dependencies of an item must
be acted upon before the item itself can be acted upon.
In use and semantics, this should be used in exactly the same way as for the
main parent class. Please note that the output of the C<depends> method is
NOT changed, as the order of the depends is not assumed to be important.
Only the output of the C<schedule> method is modified to ensure the correct
order.
For API details, see L<Algorithm::Dependency>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Diff/Callback.pm view on Meta::CPAN
package Algorithm::Diff::Callback;
# ABSTRACT: Use callbacks on computed differences
$Algorithm::Diff::Callback::VERSION = '0.111';
use strict;
use warnings;
use parent 'Exporter';
use Carp 'croak';
use List::Util 1.45 'uniq';
use Algorithm::Diff 'diff';
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
unshift @_, ($self, $1);
goto &{$self->can('call')} unless uc($1) eq $1;
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
unshift @_, ($self, $1);
goto &{$self->can('call')} unless uc($1) eq $1;
view all matches for this distribution
view release on metacpan or search on metacpan
* scripts/tide_float.pl: Changed script to make it end when
solution is found.
* lib/Algorithm/Evolutionary/Op/VectorCrossover.pm (apply): Fixed
bug: the incoming parent was modified along with the offspring.
2012-07-10 Juan J. Merelo Guervós <jjmerelo@gmail.com>
* MANIFEST: Eliminating pod.t also in production code.
2011-02-20 Juan J. Merelo Guervós <jjmerelo@gmail.com>
* lib/Algorithm/Evolutionary/Op/Breeder_Diverser.pm (apply): Made
even more diverse by not inserting the new individual if it is the
same as the parent; refactored also to best practices.
* lib/Algorithm/Evolutionary/Op/Uniform_Crossover_Diff.pm (apply):
Changed to leave at least one difference without change
2011-02-19 Juan J. Merelo Guervós <jjmerelo@gmail.com>
view all matches for this distribution
view release on metacpan or search on metacpan
or
sudo cpan Algorithm::Evolutionary::Simple
This module is apparently also available at the OpenSUSE repos. To install it, I guess, you should use:
zypper install perl-Algorithm-Evolutionary-Simple
or via YaST
view all matches for this distribution
view release on metacpan or search on metacpan
* scripts/tide_float.pl: Changed script to make it end when
solution is found.
* lib/Algorithm/Evolutionary/Op/VectorCrossover.pm (apply): Fixed
bug: the incoming parent was modified along with the offspring.
2012-07-10 Juan J. Merelo Guervós <jjmerelo@gmail.com>
* MANIFEST: Eliminating pod.t also in production code.
2011-02-20 Juan J. Merelo Guervós <jjmerelo@gmail.com>
* lib/Algorithm/Evolutionary/Op/Breeder_Diverser.pm (apply): Made
even more diverse by not inserting the new individual if it is the
same as the parent; refactored also to best practices.
* lib/Algorithm/Evolutionary/Op/Uniform_Crossover_Diff.pm (apply):
Changed to leave at least one difference without change
2011-02-19 Juan J. Merelo Guervós <jjmerelo@gmail.com>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Evolutionary/Individual/Tree.pm view on Meta::CPAN
}
=head2 closeParens
Internal subrutine: closes node parenthesis
=cut
sub closeParens {
my $node = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
examples/breeding_perls.pl view on Meta::CPAN
use Algorithm::Evolve;
Algorithm::Evolve->new(
critter_class => 'main',
selection => 'roulette',
replacement => 'rank',
parents_per_gen => 2,
size => 200,
callback => \&callback,
)->start;
sub callback {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
unless ($$sym =~ s/([^:]+)$//) {
# XXX: it looks like we can't retrieve the missing function
# via $$sym (usually $main::AUTOLOAD) in this case.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
unless ( uc($1) eq $1 ) {
unshift @_, ( $self, $1 );
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
my $cwd = Cwd::cwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
my $pwd = Cwd::cwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
}
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
my $method = $1;
if ( uc($method) eq $method ) {
view all matches for this distribution
view release on metacpan or search on metacpan
GDiffDelta.xs view on Meta::CPAN
croak("delta contains negative int value");
return buf[0] * 0x1000000 + buf[1] * 0x10000 +
buf[2] * 0x100 + buf[3];
}
/* The buffer is supplied by the parent so that we can avoid allocating
* it on the stack every time this is called, even though that probably
* wouldn't be very expensive in most implementations. */
static void
copy_data (SV *in, SV *out, size_t num_bytes, unsigned char *buf,
const char *from, const char *to)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
=item $eq->len
Returns the internal length of the coeficients vector.
Note that this value is just a hint as the internal representation
grows transparently when new coeficients are set or inside the
C<solve> method.
=back
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Algorithm/Gutter/Cell.pod view on Meta::CPAN
drains. The reference is called with the cell object, cell index in the
gutter list, how much fluid drained, and an optional I<stash> provided
by the caller.
The caller is responsible for the return value, which will be
accumulated by the parent B<drain> method and returned to the caller as
a list. For example, the B<update> code could return MIDI events, the
amount of fluid drained, both, neither, or other values as need be.
Failing to set an update callback for a cell that triggers will result
in an exception.
view all matches for this distribution