-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoneClass.py
More file actions
27 lines (20 loc) · 714 Bytes
/
Copy pathoneClass.py
File metadata and controls
27 lines (20 loc) · 714 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
trainFile = 'train/train.all_1.txt'
testFile= 'train/test.all_1.txt'
def convertFile(inputFN, outputFN, label):
fhInput = open(inputFN,'r')
fhOutput = open(outputFN, 'w')
topline = fhInput.readline()
fhOutput.write(topline)
for line in fhInput:
splitLine = line.strip().split()
fhOutput.write(splitLine[0]+" " + splitLine[1]+" "+ splitLine[2])
if str(label) in splitLine[3:]:
fhOutput.write( " 1")
else:
fhOutput.write( " 0")
fhOutput.write( "\n")
for label in range(20):
outputFNTrain = 'trainScratch/train.' + str(label)+'_1.txt'
outputFNTest = 'trainScratch/test.' + str(label)+'_1.txt'
convertFile(trainFile, outputFNTrain, label)
convertFile(testFile, outputFNTest, label)