Oct-15-2020, 10:59 PM
(Oct-15-2020, 07:06 PM)deanhystad Wrote: You need to tell us what you are trying to do, and I don't mean "Write a program to read a text from a file and perform Markov analysis." How is your program supposed to work? What do you expect this code to do?
fin=open(f,encoding='utf-8') l=((fin.read()).strip(string.punctuation).split(' '))The comment says add combind strings to dictionary, but what combined strings? What are these strings expected to look like?
for i in range(len(l)-length-1): # adds combined strings to dictionary, then assigns the word following it to the key s=' '.join(l[i:i+length]) d.setdefault(s,[]).append(l[i+length]);And what does d.setdefaults(s, []) do? Do you want to do that many times?
I don't know what the complicated parts do, I just copied the code from my friend. I don't think he was finished though, so I'm trying to get some help.