import numpy as np
import random

data_path = './data/web-Google.txt'
with open(data_path, 'r') as f:
    data = f.read().replace("\n", ",").split(",")
    del data[:5]

# add random k (0,1)
for i in range(len(data)):
    # random_k = random.randint(0, 1)
    # data[i] += '\t'+str(random_k)
    data[i] += '\t1'

#split into train/test
dataset = np.array(data)
dataset = np.random.permutation(dataset)
test_size = int(len(data)*0.2)
train_size = test_size * 4
test_data = dataset[:test_size]
train_data = dataset[test_size:]

#save files
f = open('./data/web-Google_dyrep_train.txt', 'w')
f.write('\n'.join(train_data))
f.close()
f = open('./data/web-Google_dyrep_test.txt', 'w')
f.write('\n'.join(test_data))
f.close()
