subword-nmt bpe 分词的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_18644513/article/details/88646444

为了减小词表的大小,减少未知词(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

猜你喜欢

转载自blog.csdn.net/qq_18644513/article/details/88646444
BPE
nmt
今日推荐