subword-nmt bpe 分词的使用

为了减小词表的大小,减少未知词(unk)的量,使用bpe分词:

安装:

1.sudo pip install subword-nmt
##设置词表大小3W,输入英文单语数据 train.en
2.subword-nmt learn-bpe -s 30000 < train.en > en.model
##应用BPE分词 -c 输入的词表,test.txt测试数据,并得到分词结果out.txt
3.subword-nmt apply-bpe -c en.model < test.txt > out.txt
#bpe的detoken
4.sed -r 's/(@@ )|(@@ ?$)//g' out.txt > out_detoken.txt

你可能感兴趣的:(subword-nmt bpe 分词的使用)