-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.py
More file actions
33 lines (27 loc) · 858 Bytes
/
Copy pathscripts.py
File metadata and controls
33 lines (27 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import numpy as np
def vocab_size():
base = 'paraphrases/'
files = {'test','train','test'}
words = set()
for file in files:
with open(os.path.join(base,file)) as f:
for line in f:
parts = line.strip().split('\t')
s,t = parts[0].split(' ')
words.add(s)
words.add(t)
print("Vocab Size {}".format(len(words)))
def create_splits():
base = 'paraphrases/'
prob = 0.0625
dev_writer = open(os.path.join(base,'dev'),'w')
trn_writer = open(os.path.join(base,'trn'),'w')
with open(os.path.join(base,'train')) as f:
for line in f:
if np.random.uniform(size=1) <= 0.0625:
dev_writer.write(line)
else:
trn_writer.write(line)
if __name__ == '__main__':
vocab_size()