CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
how to count sentence

 



andrewumb
New User

Oct 15, 2006, 2:19 AM

Post #1 of 4 (3731 views)
how to count sentence Can't Post

i am begginer in perl .
i wan to ask . how to count sentence in a file .
exam i have a file name "test.txt"

and contain from test.txt is :

Bob said "Hello". James responded "Hi, how are you".
Bob replied "Fine and you". andrew "bla blo ble".
Bob just sleep .

and my code is :
------------------------------------------------------

open (cc,"p.txt");
use Lingua::EN::Sentence qw( get_sentences add_acronyms );

my $sentences=get_sentences(<cc>);

$i=0;
foreach my $sentence (@$sentences) {
$arra=@$sentences->;
print "#", $sentence , ":\n";
$i=$i+1;
# chomp(@$sentences);
}
==============================

but the result is
:
Bob said "Hello".
James responded "Hi, how are you".

i cant continue to next lines , can any one suggest to me

what code is need i add , or solution ?

i wan to result like this:

Bob said "Hello".
James responded "Hi, how are you".
Bob replied "Fine and you".
andrew "bla blo ble".
Bob just sleep .


thanks for your attention


KevinR
Veteran


Oct 15, 2006, 9:40 AM

Post #2 of 4 (3727 views)
Re: [andrewumb] how to count sentence [In reply to] Can't Post


Code
use Lingua::EN::Sentence qw( get_sentences add_acronyms );  
open (CC,"p.txt");
my $i = 0;
while (<CC>) {
my $sentences=get_sentences($_);
foreach my $sentence (@$sentences) {
print "#", $sentence , ":\n";
$i++;
}
}
print "There are $i sentences."

-------------------------------------------------


andrewumb
New User

Oct 15, 2006, 8:16 PM

Post #3 of 4 (3721 views)
Re: [KevinR] how to count sentence [In reply to] Can't Post

wau . it's work , thanks

may be i will be ask more , because still newbie Sly


KevinR
Veteran


Oct 15, 2006, 10:41 PM

Post #4 of 4 (3718 views)
Re: [andrewumb] how to count sentence [In reply to] Can't Post

OK, as long as I'm doing your school/class work for you that is fine. Wink
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives