Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text::NSP

Status
Not open for further replies.

amadaeliseo

Instructor
Jul 13, 2009
2
MK
I have used Text::NSP module and have found most frequent collocations in a text, and ended with this:

Code:
 $filename = "input.txt";
  $outfile="output.txt";
  open(INPUT,$filename) or die "Can't open file $filename\n";
  open( OUTPUT, "> $outfile") or die "$filename: $!";
  undef $/; my $text=<INPUT>; close INPUT; $/ = "\n";     
  $text =~ tr/a-zåàâäæçéèêëîïôöœßùûüÿA-ZÅÀÂÄÆÇÉÈÊËÎÏÔÖŒÙÛÜ/\n/cs;
  @words = split(/\n/, $text);
  use Text::NSP::Measures::2D::MI::ll;
  my $npp = 60; my $n1p = 20; my $np1 = 20;  my $n11 = 10;
  $ll_value = calculateStatistic( n11=>$n11,
                                      n1p=>$n1p,
                                      np1=>$np1,
                                      npp=>$npp);
  if( ($errorCode = getErrorCode()))
  {
    print STDERR $errorCode." - ".getErrorMessage()."\n"";
  }
  else
  {
    print getStatisticName."value for bigram is ".$ll_value."\n"";
  }

Something is wrong and it is not working. What? How to fix it?
 
It might help if you told us what error you are getting...

Running it with strict, warnings, and possibly even diagnostics would be a good starting point.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
The problem is that there is no result in the output file. I have missed something.
 
I don't see any statements in the posted code for:

print OUTPUT " .... "; --> which points to the filehandle that you would like to see OUTPUT go to.

Are you seeing output to the screen right now?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top