-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata_pre-processing.py
More file actions
54 lines (46 loc) · 1.94 KB
/
Copy pathdata_pre-processing.py
File metadata and controls
54 lines (46 loc) · 1.94 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#=====================================================================================
#this script will eliminate the unwanted portions of feature file-
#generated by OpenSmile and store them in Numpy array formatted text files.
# Written by Mahbub Ul Alam
#=====================================================================================
#!/usr/bin/python
import os
import sys
#location of the feature file generated from openSmile.
#if you are using newer version of python then please use "input" instead of "raw_input" .
file_path = raw_input("Enter OpenSmile generated Feature containing CSV File location: ")
#if K-fold cross-validation is needed to be performed on data
#then please select All (A).
data_type = raw_input("Enter output Data Type, T for Training, D for Development, A for All: ")
# processed data will be saved in text files.
if(data_type=="T"):
output_file_name = open("training_data.txt",'w')
print("Data will be generated shortly, please check training_data.txt")
elif(data_type=="D"):
output_file_name = open("development_data.txt",'w')
print("Data will be generated shortly, please check development_data.txt file")
else:
output_file_name = open("processed_data.txt",'w')
print("Data will be generated shortly, please check processed_data.txt file")
sys.stdout = output_file_name
#data will be saved in Numpy array format
input_file = open(file_path)
count=-1
token=-1
for line in input_file.read().split('\n'):
count=-1
token=-1
if(line!='') :
if(line[0]!='@'):
for value in line.split(","):
count+=1
if(count==0):
for word in value.split("_"):
token+=1
if(token==0):
break
break;
line = line.replace(value,word)
line = line.replace('\'','')
line = line.replace(",?",'')
print (line)