#!/usr/bin/perl
open (EPL, "<../EPL/EPL.CD") or die "Can't open EPL file: $!";
open (OUTFILE, ">CelexWordFreqs.txt") or die "Can't open output file: $!\n";

$minfreq = 1;

READLINE:
while ($line = <EPL>)
{
    $items++;        
    chomp($line);
    $line =~ s/\\/\t/g;    
    ($IdNum, $Word, $Cob, $PronCnt, $PronStatus, $PhonStrsDISC, $PhonCVBr, $PhonSylBCLX, @unassigned) = split ("\t", $line);    
    
    $transcription = $PhonSylBCLX;    
    unless ($Cob < $minfreq) {
	$WordFreqs{$Word} += $Cob;    
    }
    if ($items =~ /000$/) {
        print "$transcription\n";        
    }

}
close (EPL);

foreach $word (sort keys %WordFreqs) {
    print OUTFILE "$WordFreqs{$word}\t$word\n";        
}


close (OUTFILE);
    
