forked from codebox/bayesian-classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
importfiles.py
49 lines (41 loc) · 1.97 KB
/
importfiles.py
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
def importsingleCSV(self,pars):
file_contents = ""
count=0
data=""
for sen in self.text:
if (pars):
punc= findSep(sen)
if (punc=="comma"):
data=sen.split(',')
file_contents = file_contents + (data[1])
if (punc=="space"):
data=(sen).split(' ')
file_contents = file_contents + (data[1])
if (punc=="semi-colon"):
data=(sen).split(';')
file_contents = file_contents + (data[1])
else:
file_contents = file_contents + (sen)
print(data[0])
count = count+1
return [count,file_contents]
def importsingleTXT(self,pars):
file_contents = ""
count=0
data=""
for sen in self.text:
if (pars):
punc= findSep(sen)
if (punc=="comma"):
data=(sen).split(',')
file_contents = file_contents + (data[1])
if (punc=="space"):
data=(sen).split(' ')
file_contents = file_contents + (data[1])
if (punc=="semi-colon"):
data=(sen).split(';')
file_contents = file_contents + (data[1])
else:
file_contents = file_contents + (sen)
count=count+1
return [count,file_contents]