这是一款很好用的工具包

源代码在线查看: combine-rover-controls.gawk

软件大小: 3034 K
上传用户: wanghaihah
关键词: 工具包
下载地址: 免注册下载 普通下载 VIP

相关代码

				#!/usr/local/bin/gawk -f				#				# combine-rover-controls --				#	combined several rover control files for system combination				#	(may be used recursively)				#				# $Header: /home/srilm/devel/utils/src/RCS/combine-rover-controls.gawk,v 1.2 2005/07/05 18:20:54 stolcke Exp $				#								function process_rover_control(file, weight) {									dir = file;					sub("/[^/]*$", "", dir);					if (file == dir) {						dir = "";					}									while ((status = (getline < file)) > 0) {						# deal with relative directories in rover-control file:						# prepend rover-control directory path						if ($1 !~ /^\// && dir != "") {						    $1 = dir "/" $1;						}										if ($3 != "+") {						    # handle missing lmw and wtw and system weights						    if ($2 == "") $2 = 8;						    if ($3 == "") $3 = 0;						    if ($4 == "") $4 = 1;										    # divide system weight by total number of input files						    $4 = $4 * weight;						}										print $0;					}									if (status < 0) {						print file ": " ERRNO > "/dev/stderr";						exit(1);					}					close(file);									return;				}								BEGIN {					arg_offset = 0;					ninputs = ARGC - 1;									if (ARGV[1] ~ /^lambda=/) {					    lambda = substr(ARGV[1], 8);					    ninputs -= 1;					    arg_offset += 1;					}									if (ninputs < 1) {					    print "usage: " ARGV[0] " [lambda=WEIGHTS] ROVER-CTRL1 ROVER-CTRL2 ..." \							    >> "/dev/stderr";					    exit(2);					}								        # initialize priors from lambdas				        nlambdas = split(lambda, lambdas);				        lambda_sum = 0.0;				        for (i = 1; i 				                lambda_sum += lambdas[i];				        }				        # fill in the missing lambdas with uniform values				        for (i = nlambdas + 1; i 				                lambdas[i] = (1 - lambda_sum)/(ninputs - nlambdas);				        }									for (i = 1; i 					    process_rover_control(ARGV[arg_offset + i], lambdas[i]);					}									exit(0);				}											

相关资源