Hi,
I am trying to modify the following Python Pickle program. It always starts by generating a ">". I have tried to use "print" statements but it is ignoring them. Kindly guide me how to modify the program:
I am trying to modify the following Python Pickle program. It always starts by generating a ">". I have tried to use "print" statements but it is ignoring them. Kindly guide me how to modify the program:
Python:
import pickle
#trainer program
b=open('war&peace.txt')
text=[]
print("Testing the code")
for line in b:
for word in line.split():
text.append (word)
b.close()
textset=list(set(text))
follow={}
print("Testing")
print(text)
for l in range(len(textset)):
working=[]
check=textset[l]
for w in range(len(text)-1):
if check==text[w] and text[w][-1] not in '(),.?!':
working.append(str(text[w+1]))
follow[check]=working
a=open('lexicon-luke','wb')
pickle.dump(follow,a,2)
a.close()