Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear List, HOW would do I extract a complete sentence from a text. I have the following codes to extract the concordance lines based on the search term.But it extracts the line with search term in between sentences.The following are the codes:
open INPUT, "< $filename" or die "Cannot open $filename for input: $!"; @text = <INPUT>; close (INPUT); $text = "@text"; @splittext = split(/$string/,$text); #To extract concordance lines from text for (my $i=1; $i < @splittext; $i++) { my $before = substr((' 'x10).$splittext[$i-1],-20,20); my $after = substr($splittext[$i].' 'x10,0,20); print p($before, strong($string), $after,"\n"), }
How do I extract the complete sentences from a text like the following :
I came across this before. I came down from Canada. I came back yesterday.
Thanx,

Replies are listed 'Best First'.
Re: Extract complete sentence
by Zaxo (Archbishop) on Oct 22, 2001 at 11:59 UTC

    As you might guess, CPAN has Lingua::EN::Sentence. It keeps a list of abbreviations to forestall one pungent source of error.

    Update: Also Text::Sentence.

    After Compline,
    Zaxo