📄 conjunction_generator.pl
字号:
#!/local/all/perl## script name: conjunction_generator.pl# author: Nick Rizzolo# last modified: 6/25/03# description: Use this script to generate every possible SNoW example over# a conjunctive boolean feature space.# arguments:# - <variables>: The maximum number of variables that can be active in a# training or testing example. In other words, the# dimensionality of the feature space (excluding target IDs).# - <var#>: Each <var#> argument represents the zero-based integer index# of another variable in the conjunctive concept and must be# less than the value of the <variables> argument.# output: Every SNoW example over the feature space labeled according# to the boolean function that is the conjunction of the# variables specified by the <var#> arguments. The target IDs# (labels) will be 0 (for negative) and 1 (for positive). The# feature IDs representing the variables specified each have# value 2 higher than the index of the variable they# represent.die "usage: conjunction_generator.pl <variables> <var1> [<var2> [...]]\n" unless @ARGV > 1;$variables = $ARGV[0];for $i (1 .. $variables){ push @variable, 0; }do{ for ($i = 1; $i < @ARGV && $variable[$ARGV[$i]]; $i++) { } if ($i < @ARGV) { $example = "0"; } else { $example = "1"; } for ($i = 0; $i < @variable; $i++) { if ($variable[$i]) { $example .= ", " . ($i + 2); } } print "$example:\n";} while (test() && increment());sub test{ for ($i = 0; $i < @variable && $variable[$i]; $i++) { } return $i < @variable;}sub increment{ for ($i = 0, $add = 1; $i < @variable && $add; $i++) { $variable[$i] += $add; $add = int($variable[$i] / 2); $variable[$i] %= 2; } return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -