This assumes you can get the words into an array:
@x = qw[ this is the text to play with ];; $n = 2; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is is the the text text to to play play with $n = 3; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is the is the text the text to text to play to play with $n = 4; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is the text is the text to the text to play text to play with $n = 5; print @x[ $_ .. $_+$n-1 ] for 0 .. (@x - $n);; this is the text to is the text to play the text to play with
In reply to Re: Create n-grams from tokenized text file
by BrowserUk
in thread Create n-grams from tokenized text file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |