shuffle two files with the same order

http://unix.stackexchange.com/questions/220390/shuffle-two-parallel-text-files
macの場合はgshuf.
大規模なパラレルコーパスをランダムに(素早く)並び替えたいときなど。

#!/bin/sh

# set bigger number if it fails (e.g. 4096)
dd if=/dev/random of=myrand count=2048 1>/dev/null 2>/dev/null

shuf --random-source=myrand $1 > $1.shuf
shuf --random-source=myrand $2 > $2.shuf

タグ:

nlp linux
最終更新:2017年01月15日 00:49