Skip to content
Snippets Groups Projects
Commit 15818ef6 authored by Jan Trmal's avatar Jan Trmal
Browse files

(egs/wsj/s5) Adding a new script summarize_logs.pl

The script functions just like the summarize_warnings.pl, but greps for more
interresting events (ATM, warnings _and_ errors) -- in some cases it is good
to know that some (non-fatal) errors occured. These errors _were_ non-fatal 
in the sense that the script continued on running -- but that does not mean
everything was fine.


git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@2974 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent 5d230b07
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/perl
# Copyright 2012 Johns Hopkins University (Author: Daniel Povey). Apache 2.0.
@ARGV != 1 && print STDERR "Usage: summarize_warnings.pl <log-dir>\n" && exit 1;
$dir = $ARGV[0];
! -d $dir && print STDERR "summarize_warnings.pl: no such directory $dir\n" && exit 1;
$dir =~ s:/$::; # Remove trailing slash.
# Group the files into categories where all have the same base-name.
foreach $f (glob ("$dir/*.log")) {
$f_category = $f;
# do next expression twice; s///g doesn't work as they overlap.
$f_category =~ s:\.\d+\.:.*.:;
$f_category =~ s:\.\d+\.:.*.:;
$fmap{$f_category} .= " $f";
}
sub split_hundreds { # split list of filenames into groups of 100.
my $names = shift @_;
my @A = split(" ", $names);
my @ans = ();
while (@A > 0) {
my $group = "";
for ($x = 0; $x < 100 && @A>0; $x++) {
$fname = pop @A;
$group .= "$fname ";
}
push @ans, $group;
}
return @ans;
}
foreach $c (keys %fmap) {
$n = 0;
foreach $fgroup (split_hundreds($fmap{$c})) {
$n += `grep -w WARNING $fgroup | wc -l`;
}
if ($n != 0) {
print "$n warnings in $c\n"
}
}
foreach $c (keys %fmap) {
$n = 0;
foreach $fgroup (split_hundreds($fmap{$c})) {
$n += `grep -w ERROR $fgroup | wc -l`;
}
if ($n != 0) {
print "$n errors in $c\n"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment