0

我的数据文件包含第一个实体是字符串标签后跟特征的行。例如:

MEMO |f write down this note
CALL |f call jim's cell

问题是 Vowpal Wabbit 只接受整数标签。如何快速从字符串标签更改为唯一整数 ID 并返回?也就是快速修改数据文件为:

1 |f write down this note
2 |f call jim's cell

...并在需要时返回。

对于我的示例数据集,我使用“sed”为每个类手动完成,但这严重破坏了我的工作流程。

4

1 回答 1

1
cat input.data | perl -nale '$i=$m{$F[0]}; $i or $i=$m{$F[0]}=++$n; $F[0]=$i; print "@F"; END{warn "$_ $m{$_}\n" for sort {$m{$a}<=>$m{$b}} keys %m}' > output.data 2> mapping.txt
于 2015-01-20T10:49:33.023 回答