Keep It Simple, Stupid | |
PerlMonks |
Re: improving speed in ngrams algorithm (updated)by LanX (Saint) |
on Jun 11, 2019 at 11:04 UTC ( [id://11101227]=note: print w/replies, xml ) | Need Help?? |
Please ignore! Misunderstood question.My answer treats ngrams on characters not words.
A regex should be faster, this demo in the debugger for n=3 should give you a start.
NB:
(I know it's possible in a single regex without looping over start by playing around with \K or similar. I'll leave it to the regex gurus like tybalt to show it ;-) HTH! :)
Cheers Rolf
updateIn case you want really want to include non-letters try unpack
In Section
Seekers of Perl Wisdom
|
|