#!/usr/local/bin/perl # $Id: trec-kekka-irex.perl,v 3.1 1999/06/04 06:29:30 tsuchiya Exp $ # This file is part of IREX tools. # Please refer "Copyright file" at the root directory. # (C) IREX committee IREX実行委員会. All rights reserved. require 5.000; use lib ( "$ENV{IREX_ROOT}/IR_TOOLS/perl", "$ENV{IREX_ROOT}/perl" ); use TREC::Kekka qw( :parser ); use IREX::Kekka qw( :generator ); use IREX::Tougou qw( system_id_list ); use File::Basename; $PROGRAM = basename( $0 ); $SUFFIX = 'irt'; #------------------------------------------------------------ # コマンドラインオプションの解析 #------------------------------------------------------------ while( $_=shift(@ARGV) ){ if( /^-(h|\?|-help)$/ ){ &print_usage; } elsif( /^-(f|-prefix)$/ ){ $BASENAME = shift @ARGV; } elsif( /^-(n|-debug)$/ ){ $DEBUG = 1; } elsif( /^-(q|-quiet)$/ ){ $SILENT = 1; } else { push( @FILE,$_ ); } } unless( @FILE ){ push( @FILE,"STDIN" ); $STDIN = 1; } &print_usage if ( $DEBUG==0 )&( ! defined($BASENAME) ); #------------------------------------------------------------ # 本体 #------------------------------------------------------------ for $f ( @FILE ){ if( $STDIN ){ @BUF = ; } else { open( FILE,"< $f" ) or warn( "Can't open file to read: $f\n" ), &print_usage; print STDERR "Reading $f\n" unless $SILENT; @BUF = ; close FILE; } print STDERR "Parsing $f ...\n" unless $SILENT; &parse()||die "Parse error occured: $f\n"; } #------------------------------------------------------------ # データを整列して出力 #------------------------------------------------------------ for $system_id ( &system_id_list() ){ ( $system_id =~ /^([0-9]+)([A-z]*)$/ ) or die "Illegal system id : $system_id\n"; my $num = $1; my $str = $2; my $file; unless( $DEBUG ){ $file = sprintf( "%s_%04d%s.%s",$BASENAME,$num,$str,$SUFFIX ); if( -f $file ){ print STDERR "File is already exists: $file\nSkip.\n"; next; } else { open( FILE,"> $file" )|| die "Can't open file to write: $file\n"; select FILE; print STDERR "Writing $file ...\n" unless $SILENT; } } else { print STDERR "Printing data whose system id is $system_id ...\n" unless $SILENT; } &generate( $system_id ); if( $file ){ close FILE; select STDOUT; } } #------------------------------------------------------------ # 簡易ヘルプ #------------------------------------------------------------ sub print_usage { die <<"__END_OF_USAGE__"; Usage: $PROGRAM -f prefix teisyutsu_1 teisyutsu_2 ... teisyutsu_n 複数の TREC 結果提出ファイル teisyutu_1 teisyutu_2 ... teisyutu_n を読み込んで、複数の IREX 結果提出ファイルに変換する。変換結果は、 SYSTEM-ID によって異なるファイルに格納される。そのファイル名は -f によって指定され、次のような形式になる。 prefix_????.$SUFFIX ???? の部分には SYSTEM-ID が入る。 入力ファイルを指定しなかった場合は、標準入力からデータを取り出す。 -q オプションを指定しなければ、処理の進行状況を標準エラー出力に出 力する。 __END_OF_USAGE__ }