Hi,
i want to split the sentences into words and count its frequency. i have tried using the code below but it doesn't worked. This code actually from the text book.
----Data----
If milk goes bad if not refrigerated
Jones in rush to contribute for Bears (AP): Kevin Jones burst through the seam, sidestepped a defender as he cut.. so tired ugghhh. . . .#photog #photography
@RWZombie I am attending your Detroit show on 11/27! I want to hear the best of the new stuff. What and Sick Bubblegum plus many classics!
B & B - Vallejo & Napa Valley @onlylilia Annual Holiday party in Dec. Planning now. A concert, wine tasting and Hors d'Oeuvres
Real estate agents, worldwide. Expand your listings under contract, worldwide.\
Costa Rica, small country incredible biodiversity: tropical rain forests, dense cloud forests, active volcanoes. @Teerlink biking>gardening>schoolwork
@JSRWeek In RB, Molly Pitcher has a tasty brunch & I've heard good things about 2Senza too. In AP, Yvonne's Cafe is awesome!
# Check This Video --- Best Real Estate Deals,Hallandale Beach, FL 33009 another top XeeSM user - cool blog
@Fashion_iLIKE thanks for putting me on your special FF list ; ) Ages: 5 to 7 years at Familia! Los quiero a todo! I want to send a special shout to all the Boricuas around the world & those that made the trip to NYC this wknd!
Chabad.org goes mobile:
Any help is much appreciated. Thank You
i want to split the sentences into words and count its frequency. i have tried using the code below but it doesn't worked. This code actually from the text book.
----Data----
If milk goes bad if not refrigerated
Jones in rush to contribute for Bears (AP): Kevin Jones burst through the seam, sidestepped a defender as he cut.. so tired ugghhh. . . .#photog #photography
@RWZombie I am attending your Detroit show on 11/27! I want to hear the best of the new stuff. What and Sick Bubblegum plus many classics!
B & B - Vallejo & Napa Valley @onlylilia Annual Holiday party in Dec. Planning now. A concert, wine tasting and Hors d'Oeuvres
Real estate agents, worldwide. Expand your listings under contract, worldwide.\
Costa Rica, small country incredible biodiversity: tropical rain forests, dense cloud forests, active volcanoes. @Teerlink biking>gardening>schoolwork
@JSRWeek In RB, Molly Pitcher has a tasty brunch & I've heard good things about 2Senza too. In AP, Yvonne's Cafe is awesome!
# Check This Video --- Best Real Estate Deals,Hallandale Beach, FL 33009 another top XeeSM user - cool blog
@Fashion_iLIKE thanks for putting me on your special FF list ; ) Ages: 5 to 7 years at Familia! Los quiero a todo! I want to send a special shout to all the Boricuas around the world & those that made the trip to NYC this wknd!
Chabad.org goes mobile:
Code:
use strict;
use warnings;
open( IN, 'sentences.txt' ) or die;
open( OUT, ">word.csv" ) or die;
while (<IN>) {
chomp;
$- = lc; # Convert to lowercase
s/[.,:;?"!()]//g; # Remove most punctuation
s/--//g; # Remove dashes
s/ +/ /g; # Replace multiple spaces by one space
if ( not /^$/ ) { # Ignore empty lines
@words = split(/ /);
foreach $x (@words) {
++$tokens;
++$freq{$x};
}
$types = scalar keys %freq;
$ratio = $tokens / $types;
print OUT "$tokens, $types, $ratio\n";
}
}
Any help is much appreciated. Thank You