in reply to finding number of contiguous letters
Of course, if you need to keep track of the order in which the 3-grams occur, having them stored as hash keys would not be very useful.use Text::Ngram qw(ngram_counts add_to_counts); my $text = "abcdefghijklmnop"; my $hash_r = ngram_counts($text, 3); # Window size = 3 # $hash_r => { abc => 1, bcd => 1, ... }
(BTW, you said "I need to take a string and find the number of 3 contiguous letters" -- to be precise, the number of 3-grams in a string is simply length( $string ) - 2 ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: finding number of contiguous letters
by GrandFather (Saint) on May 23, 2007 at 08:11 UTC | |
by Skeeve (Parson) on May 23, 2007 at 12:31 UTC | |
by Limbic~Region (Chancellor) on May 23, 2007 at 12:44 UTC | |
by GrandFather (Saint) on May 23, 2007 at 21:01 UTC | |
by Limbic~Region (Chancellor) on May 24, 2007 at 12:39 UTC | |
by GrandFather (Saint) on May 24, 2007 at 21:47 UTC | |
|
Re^2: finding number of contiguous letters
by andreas1234567 (Vicar) on May 23, 2007 at 11:10 UTC | |
by graff (Chancellor) on May 23, 2007 at 11:36 UTC | |
by blazar (Canon) on May 23, 2007 at 11:40 UTC | |
by andreas1234567 (Vicar) on May 23, 2007 at 12:04 UTC |