Python Forum
Markov Analysis not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Markov Analysis not working
#3
(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.
Reply


Messages In This Thread
Markov Analysis not working - by 5Head - Oct-15-2020, 05:25 PM
RE: Markov Analysis not working - by deanhystad - Oct-15-2020, 07:06 PM
RE: Markov Analysis not working - by 5Head - Oct-15-2020, 10:59 PM
RE: Markov Analysis not working - by jefsummers - Oct-16-2020, 01:34 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020