Skip Menu |

This queue is for tickets about the Text-NGrammer CPAN distribution.

Report information
The Basics
Id: 125980
Status: resolved
Priority: 0/
Queue: Text-NGrammer

People
Owner: NIDS [...] cpan.org
Requestors: diegodelima.poa [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.04



Subject: 3-gram bug
Date: Wed, 1 Aug 2018 15:33:15 -0300
To: bug-Text-NGrammer [...] rt.cpan.org
From: Diego De Lima <diegodelima.poa [...] gmail.com>
Bug on 3-gram generations (bi-grams are OK). LINE 42:   my @ngrams = ();   my $step = $k + 1;   for (my $i = 0; $i <= ($length - ($n+($k*($n-1)))); $i += 1) {     my @tokens = ();     push @tokens, $_[$i];     while (@tokens < $n) {       push @tokens, $_[$i + ($k+1)];     }     push @ngrams, \@tokens;   } SHOULD BE:   my @ngrams = ();   my $step = $k + 1; for (my $i = 0; $i <= ($length - ($n+($k*($n-1)))); $i += 1) {     my @tokens = ();     push @tokens, $_[$i];   my $pos = 0;     while (@tokens < $n) {       push @tokens, $_[$i + ($k+$pos+1)]; $pos++;     }     push @ngrams, \@tokens;   } Best Regards, Diego de Lima

Message body is not shown because it is too large.

Unfortunately the provided fix wouldn't have worked for skipgrams. Version 0.04 fixes the problem. Thanks for reporting :) Show quoted text
> Bug on 3-gram generations (bi-grams are OK). > > LINE 42: > >   my @ngrams = (); >   my $step = $k + 1; >   for (my $i = 0; $i <= ($length - ($n+($k*($n-1)))); $i += 1) { >     my @tokens = (); >     push @tokens, $_[$i]; >     while (@tokens < $n) { >       push @tokens, $_[$i + ($k+1)]; >     } >     push @ngrams, \@tokens; >   } > > > SHOULD BE: > >   my @ngrams = (); >   my $step = $k + 1; > for (my $i = 0; $i <= ($length - ($n+($k*($n-1)))); $i += 1) { >     my @tokens = (); >     push @tokens, $_[$i]; >   my $pos = 0; >     while (@tokens < $n) { >       push @tokens, $_[$i + ($k+$pos+1)]; > $pos++; >     } >     push @ngrams, \@tokens; >   } > > > Best Regards, > > Diego de Lima