【发布时间】:2019-05-12 23:09:35
【问题描述】:
我正在从事一个机器翻译项目,其中有 450 万行文本,有两种语言,English 和 German。在将数据划分为我将在其上训练我的模型的碎片之前,我想对这些行进行洗牌。我知道shuf 描述的shuf 命令允许一个文件中的行洗牌,但我怎样才能确保第二个文件中的相应行也洗牌成相同的顺序?是否有命令可以将两个文件中的行打乱?
【问题讨论】:
标签: nlp shuffle training-data
我正在从事一个机器翻译项目,其中有 450 万行文本,有两种语言,English 和 German。在将数据划分为我将在其上训练我的模型的碎片之前,我想对这些行进行洗牌。我知道shuf 描述的shuf 命令允许一个文件中的行洗牌,但我怎样才能确保第二个文件中的相应行也洗牌成相同的顺序?是否有命令可以将两个文件中的行打乱?
【问题讨论】:
标签: nlp shuffle training-data
paste 将两个文件的单独列创建到一个文件中shuf 在单个文件上cut 拆分列粘贴
$ cat test.en
a b c
d e f
g h i
$ cat test.de
1 2 3
4 5 6
7 8 9
$ paste test.en test.de > test.en-de
$ cat test.en-de
a b c 1 2 3
d e f 4 5 6
g h i 7 8 9
随机播放
$ shuf test.en-de > test.en-de.shuf
$ cat test.en-de.shuf
d e f 4 5 6
a b c 1 2 3
g h i 7 8 9
剪切
$ cut -f1 test.en-de.shuf> test.en-de.shuf.en
$ cut -f2 test.en-de.shuf> test.en-de.shuf.de
$ cat test.en-de.shuf.en
d e f
a b c
g h i
$ cat test.en-de.shuf.de
4 5 6
1 2 3
7 8 9
【讨论】: