data_prepare.sh 1.8 KB
Newer Older
1 2
#! /bin/bash

T
tangwei 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

M
malin10 已提交
17 18 19
mkdir -p data/all_dict
mkdir -p data/all_train
mkdir -p data/all_test
T
tangwei 已提交
20

21 22
# download train_data
mkdir raw_data
M
bug fix  
malin10 已提交
23
wget --no-check-certificate https://paddlerec.bj.bcebos.com/word2vec/1-billion-word-language-modeling-benchmark-r13output.tar
24 25 26
tar xvf 1-billion-word-language-modeling-benchmark-r13output.tar
mv 1-billion-word-language-modeling-benchmark-r13output/training-monolingual.tokenized.shuffled/ raw_data/

M
malin10 已提交
27
# download test data
M
bug fix  
malin10 已提交
28
wget --no-check-certificate https://paddlerec.bj.bcebos.com/word2vec/test_dir.tar
M
malin10 已提交
29 30 31
tar xzvf test_dir.tar -C raw_data
mv raw_data/data/test_dir/* data/all_test/

32
# preprocess data
M
malin10 已提交
33 34
python preprocess.py --build_dict --build_dict_corpus_dir raw_data/training-monolingual.tokenized.shuffled --dict_path raw_data/word_count_dict.txt
python preprocess.py --filter_corpus --dict_path raw_data/word_count_dict.txt --input_corpus_dir raw_data/training-monolingual.tokenized.shuffled --output_corpus_dir raw_data/convert_text8 --min_count 5 --downsample 0.001
M
malin10 已提交
35
python preprocess.py --data_resplit --input_corpus_dir=raw_data/convert_text8 --output_corpus_dir=data/all_train
36

M
malin10 已提交
37 38
mv raw_data/word_count_dict.txt data/all_dict/
mv raw_data/word_count_dict.txt_word_to_id_ data/all_dict/word_id_dict.txt
39
rm -rf raw_data