in reply to Re^2: sorting text into sentences.
in thread sorting text into sentences.
Now the perl code:C:\Temp>type t.txt This is a test sentence. And this is another one; Also so is this. And by the way, this is the fourth sentence.
Now the output:#!/usr/bin/perl use strict; use warnings; my $s; my @arr; open(FILE, "<t.txt"); while(<FILE>) { chomp $_; $s .= $_; } @arr = $s =~ m/[A-Z].+?[.;]/g; foreach (@arr) { print $_, "\n"; }
as you can see, each array position in @arr contains 1 sentence (as you have defined it).C:\Temp>t.pl This is a test sentence. And this is another one; Also so is this. And by the way, this is the fourth sentence.
hope this helps,
davidj
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: sorting text into sentences.
by chiburashka (Initiate) on Sep 06, 2004 at 08:12 UTC | |
by ysth (Canon) on Sep 06, 2004 at 08:18 UTC | |
by chiburashka (Initiate) on Sep 06, 2004 at 09:14 UTC | |
by ysth (Canon) on Sep 06, 2004 at 09:23 UTC | |
by ysth (Canon) on Sep 06, 2004 at 09:35 UTC |