PDL::Ngrams - N-Gram utilities for PDL
use PDL; use PDL::Ngrams; ##--------------------------------------------------------------------- ## Basic Data $toks = rint(10*random(10)); ##--------------------------------------------------------------------- ## ... stuff happens
PDL::Ngrams provides basic utilities for tracking N-grams over PDL vectors.
Signature: (toks(@adims,N,NToks); %args) Returns: (int [o]ngramfreqs(NNgrams); [o]ngramids(@adims,N,NNgrams))
Keyword arguments (optional):
norotate => $bool, ##-- if true, $toks() will NOT be rotated along $N boffsets => $boffsets(NBlocks) ##-- block-offsets in $toks() along $NToks delims => $delims(@adims,N,NDelims) ##-- delimiters to splice in at block boundaries
Count co-occurrences (esp. N-Grams) over a token vector $toks. This function really just wraps ng_delimit(), ng_rotate(), vv_qsortvec(), and rlevec().
Signature: (toks(@adims,N,NToks); [o]rtoks(@adims,N,NToks-N+1))
Create a co-occurrence matrix by rotating a (delimited) token vector $toks(). Returns a matrix $rtoks() suitable for passing to ng_cofreq().
The following functions can be used to add or remove delimiters to a PDL vector. This can be useful to add or remove beginning- and/or end-of-word markers to rsp. from a PDL vector, before rsp. after constructing a vector of N-gram vectors.
Signature: (toks(NToks); indx boffsets(NBlocks); delims(NDelims); [o]dtoks(NDToks))
Add block-delimiters (e.g. BOS,EOS) to a vector of raw tokens.
See "ng_delimit" in PDL::Ngrams::ngutils.
Signature: (dtoks(NDToks); indx boffsets(NBlocks); int NDelims(); [o]toks(NToks))
Remove block-delimiters (e.g. BOS,EOS) from a vector of delimited tokens.
See "ng_undelimit" in PDL::Ngrams::ngutils.
Some additional low-level functions are provided in the PDL::Ngrams::ngutils package. See PDL::Ngrams::ngutils for details.
perl by Larry Wall.
Bryan Jurish <moocow@cpan.org>
PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others.
Copyright (c) 2007-2015, Bryan Jurish. All rights reserved.
This package is free software. You may redistribute it and/or modify it under the same terms as Perl itself.
perl(1), PDL(3perl), PDL::Ngrams::ngutils(3perl)
To install PDL::Ngrams, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PDL::Ngrams
CPAN shell
perl -MCPAN -e shell install PDL::Ngrams
For more information on module installation, please visit the detailed CPAN module installation guide.