-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.py
43 lines (39 loc) · 1006 Bytes
/
parser.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
import os
import pickle
def writer():
import re
mydir = os.getcwd()
try:
toWrite = []
infile = open(mydir+"/pickles/words.pkl", "rb")
info = pickle.load(infile)
for sentence in info:
mysentence = sentence.lower()
instances = []
for inst in re.finditer("take note", mysentence):
instances.append(inst.start())
if len(instances) == 0:
pass
elif len(instances) == 1:
toWrite.append(sentence[instances[0]:])
else:
print(len(instances))
for idx, stridx in instances[:-1]:
toWrite.append(sentence[stridx:instances[idx+1]])
toWrite.append(sentence[instances[len(instances)-1]:])
infile.close()
#os.remove(mydir+"/pickles/words.pkl")
f = open(mydir+"/output/notes.txt","w")
for phrase in toWrite:
f.write(phrase)
f.write("\n")
f.close()
os.system("open " + mydir + "/output/notes.txt")
except EOFError:
print("\n")
print("ERROR: No notes taken!")
exit(1)
print("\n\n")
print("Transcription Complete")
print("\n\n")
exit(0)