LDAC(3pm) | User Contributed Perl Documentation | LDAC(3pm) |
PDL::CCS::IO::LDAC - LDA-C format text I/O for PDL::CCS::Nd
use PDL; use PDL::CCS::Nd; use PDL::CCS::IO::LDAC; ##-- (Document x Term) matrix $dtm = PDL::CCS::Nd->newFromWhich($which,$nzvals); ccs_writeldac($dtm,"dtm.ldac"); # write a sparse LDA-C text file $dtm2 = ccs_readldac("dtm.ldac"); # read a sparse LDA-C text file ###-- (Term x Document) matrix in document-primary format $tdm = $dtm->xchg(0,1)->make_physically_indexed(); ccs_writeldac($tdm,"tdm.ldac", {transpose=>1}); $dtm2 = ccs_readldac("tdm.ldac", {transpose=>1});
Write a 2d PDL::CCS::Nd (Document x Term) matrix as an LDA-C text file. If the "transpose" option is specified and true, the input matrix $ccs is treated as as a (Term x Document) matrix, and output lines correspond to logical dimension 1 of $ccs. Otherwise, output lines correspond to logical dimension 0 of $ccs, which is expected to be a (Document x Term) matrix.
ccs_writeldac($ccs,$filename_or_fh) ccs_writeldac($ccs,$filename_or_fh,\%opts)
Options %opts:
header => $bool, ##-- do/don't write a header to the output file (default=do) transpose => $bool, ##-- treat input $ccs as (Term x Document) matrix (default=don't)
Read a 2d (Document x Term) matrix from an LDA-C text file as a PDL::CCS::Nd object. If the "transpose" option is specified and true, the output matrix $ccs will be a (Term x Document) matrix, and input lines correspond to logical dimension 1 of $ccs. Otherwise, input lines correspond to logical dimension 0 of $ccs, which will be returned as a (Document x Term) matrix.
$ccs = ccs_readldac($filename_or_fh) $ccs = ccs_readldac($filename_or_fh,\%opts)
Options %opts:
header => $bool, ##-- do/don't try to read header data from the output file (default=do) type => $type, ##-- value datatype (default: from header or $PDL::IO::Misc::deftype) transpose => $bool, ##-- generate a (Term x Document) matrix (default=don't) sorted => $bool, ##-- assume input is lexicographically sorted (only if not transposed; default=don't)
Perl by Larry Wall.
PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others.
LDA-C package by by David M. Blei.
Bryan Jurish <moocow@cpan.org>
Copyright (C) 2015-2022, Bryan Jurish. All rights reserved.
This package is free software, and entirely without warranty. You may redistribute it and/or modify it under the same terms as Perl itself.
perl, PDL, PDL::CCS::Nd, PDL::CCS::IO::FastRaw, PDL::CCS::IO::FITS, PDL::CCS::IO::MatrixMarket, the LDA-C package documentation at <http://www.cs.princeton.edu/~blei/lda-c/> ...
2022-12-02 | perl v5.36.0 |