my $x= "it is not probably that it is the end";
my @wds = split(' ',$x);
push @ngram, join(" ",@wds[0..2]);
it is not
is not probably
not probably that
probably that it
that it is
it is the
is the end
Thanks for the help. And in the same script which you have provided me few days ago and i also modified and posted yesterday. In that i want the comparison to be case-sensitive which means all words should be compared without case-sensitivesness..
for eg. If i have the word "finding" in the candidate and "Finding" in reference. The present script dont give the count in reference for that word, since it has capital F.
So, how can deal with this case-sensitive problem. Any help plz
I'm not sure what you need. To count the number of occurrences of "finding" in a case insensitive way would require the /i switch for case_insensitive and then the /g switch to keep going globally.
There is a critter, called the goatse operator, "=()=" that will give the scalar count of the number of matches. You can read about it here: goatse operator. Or just look at the code and play with it..
my $x = "Finding fiNding fIndinG finding";
my $count = () = $x =~ /finding/ig;
print "$count\n"; #prints 4