Algorithm-LDA

 view release on metacpan or  search on metacpan

bin/lda.pl  view on Meta::CPAN

#                               THE CODE STARTS HERE
###############################################################################

#                           ================================
#                            COMMAND LINE OPTIONS AND USAGE
#                           ================================

use Getopt::Long;
use Algorithm::LDA;

eval(GetOptions( "version", "help", "topics=s", "stop=s", "iterations=s")) or die ("Please check the above mentioned option(s).\n");

#  if help is defined, print out help
if( defined $opt_help ) {    
    $opt_help = 1;
    &showHelp();
    exit;
}

#  if version is requested, show version
if( defined $opt_version ) {

bin/lda.pl  view on Meta::CPAN

    $stop = $opt_stop; 
}

# TODO -- add as options
# $maxIterations - Maximum Iterations
# $updateCorpus - 1 = Force update documents, 0 = allow loading from JSON
# $wordThreshold - Minimum number of documents a word must appear in
# $alpha - Default Alpha value
# $numWords - Number of words per topic
my $maxIterations = 1000;
if(defined $opt_iterations) { 
    $maxIterations = $opt_iterations; 
}
my $updateCorpus = 0;
my $wordThreshold = 10;
my $alpha = 0.1;
my $numWords = 5;


my $test = new Algorithm::LDA($dir, $numTopics, $maxIterations, $totalDocs, $updateCorpus, $wordThreshold, $alpha, $numWords, $stop);

##############################################################################

bin/lda.pl  view on Meta::CPAN

    print "Usage: lda.pl [OPTIONS] DIR\n\n";

    print "General Options:\n\n";

    print "--version                Prints the version number\n\n";
    
    print "--help                   Prints this help message.\n\n";

    print "--stoplist FILE          A file containing a list of words to be excluded\n\n";
    
    print "--iterations NUM         Max number of iterations [Default: 1000]\n\n";

    print "--topics NUM             Number of topics [Default: 10]\n\n";

}

##############################################################################
#  function to output the version number
##############################################################################
sub showVersion {
    print '$Id: lda.pl,v 1.114 2016/07/12 20:18:30 btmcinnes Exp $';



( run in 1.408 second using v1.01-cache-2.11-cpan-96521ef73a4 )