#!/usr/bin/perl -w

#    prepare-clauses-all-text-files.pl
#    Version 1.1

#    Kea -- Automatic Keyphrase Extraction
#    Copyright 1998-1999 by Gordon Paynter and Eibe Frank
#    Contact gwp@cs.waikato.ac.nz or eibe@cs.waikato.ac.nz
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# Version history
#
# 1.0   Witten et.al.
# 1.0.1 Check parameters
# 1.0.2 Use "perl -w' to run prepare-clauses.pl
# 1.1   First Distribution.  GPL added.

if (!$ARGV[0]) {
    die "Usage: prepare-clauses-all-text-files.pl <directory>\n";
}

$directory = $ARGV[0];
$directory =~ s/\/$//;

$documents = `find $directory/ -name "*.txt"`;
@documents = split(/\s+/, $documents);

foreach $in (@documents) {
    ($out) = $in =~ /(.+).txt/;
    $out .= ".clauses";

    `perl -w prepare-clauses.pl $in $out`;
}

