in reply to sorting text into sentences.

I really want to help you, but I do not understand what you are asking. Could you please clarify your question.

davidj

Replies are listed 'Best First'.
Re^2: sorting text into sentences.
by chiburashka (Initiate) on Sep 06, 2004 at 07:44 UTC
    Thanks for the will to help. Look i open a file that contains text(e.g perlref.txt), and i want to make eventually an array, that every index of which will contain every line (accordingly) by the next rules :
    1. every line shold start with a capital letter.
    2. every line should end with "." or ";"
    3. befor every line's begining there should be the character "." or ";" (let's even assume that before the first line there's a dot.)

    "If you know the right question to ask, you already know the answer."
      This will do it for you.

      Sample text file:
      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 perl code:
      #!/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"; }
      Now the output:
      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.
      as you can see, each array position in @arr contains 1 sentence (as you have defined it).

      hope this helps,

      davidj

        Thanks a lot, but i already made a code :
        #!/usr/bin/perl -w use Strict; $dat = "a.txt"; open(DAT, "$dat") || die "Can't open the file.\n"; @a=<DAT>; close(DAT); my $temp3; foreach (@a) {chomp $_; $temp3 .= "$_ "} @a = split(/.,;/, $temp3); foreach (@a) {$_ .= "\n";} print @a;
        "If you know the right question to ask, you already know the answer."