Algorithm::WordLevelStatistics

Pure Perl implementation of the "words level statistics" algorithm
Download

Algorithm::WordLevelStatistics Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Francesco Nidito
  • Publisher web site:
  • http://search.cpan.org/~nids/

Algorithm::WordLevelStatistics Tags


Algorithm::WordLevelStatistics Description

Pure Perl implementation of the "words level statistics" algorithm Algorithm::WordLevelStatistics is a Perl module that implements the word leval statistics algorithm as described in: P. Carpena, P. Bernaola-Galav, M. Hackenberg, A.V. Coronado and J.L. Oliver, "Level statistics of words: finding keywords in literary texts and DNA", Physical Review E 79, 035102-4 ( DOI: 10.1103/PhysRevE.79.035102 )SYNOPSIS use Algorithm::WordLevelStatistics; my $wls = Algorithm::WordLevelStatistics->new; my %spectra = (); # hash from word to positions open IN, "< file.txt" or die "cannot open file.txt: $!"; my $idx = 0; while(< IN >) { chomp; next if(m/^\s*$/); #skip blank lines foreach my $w ( split /\W/, lc( $_ ) ) { next if($w =~ m/^\s*$/); push @{ $spectra{$w} }, $idx++; } } close IN; my $ws = $wls->compute_spectra( \%spectra ); # sort the words by their C attribute (the deviation of sigma_nor with respect to the expected value in a random text) my @sw = sort { $ws->{$b}->{C} $ws->{$a}->{C} } keys( %{ $ws } ); # print all the words with their scores foreach my $i (@sw) { print $i, " => { C = ",$ws->{$i}->{C}, ", count = ", $ws->{$i}->{count}, ", sigma_nor = ", $ws->{$i}->{sigma_nor}," }\n"; } Requirements: · Perl


Algorithm::WordLevelStatistics Related Software