Python Forum
AttributeError: 'Response' object has no attribute 'replace'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: 'Response' object has no attribute 'replace'
#11
(Mar-19-2019, 11:43 PM)Truman Wrote: Wouldn't it be more 'fair' that each word has an equal chance of being selected?

What's fair got to do with it? He wants to create a list of words with the same distribution as that for the original text. Not all the words are used the same number of times in the original text. And you'll note that he's doing it by pairs of words. So you start with 'I', and then pick a word based on it's probability of occurring after 'I' in the original text. Say you pick 'can'. Next you pick the third word based on it's probability of occurring after 'can' in the original text. And so on. This gives you a random sentence that matches the conditional probabilities of the random text. It will probably almost but not really make sense. If you chose the words with the same probability, without looking at what words come after other words, it would be complete gibberish.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#12
Does value represent a number of times that word appears in the text?
Reply
#13
Again, remember that it's a two level dictionary. So wordDict[word1][word2] is the number of times that word2 appears after word1, in the text.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: 'NoneType' object in a parser - stops it apollo 4 1,118 May-28-2021, 02:13 PM
Last Post: Daring_T
  AttributeError: ResultSet object has no attribute 'get_text' KatMac 1 1,141 May-07-2021, 05:32 PM
Last Post: snippsat
  Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text' fudgemasterultra 1 3,279 Mar-03-2021, 09:40 AM
Last Post: Larz60+
  'NavigableString' object has no attribute 'h2' RandomCoder 5 2,072 May-20-2020, 09:01 AM
Last Post: Larz60+
  AttributeError: 'str' object has no attribute 'xpath' nazmulfinance 4 5,172 Nov-11-2019, 05:15 PM
Last Post: nazmulfinance
  AttributeError: 'str' object has no attribute 'xpath' nazmulfinance 0 1,329 Nov-10-2019, 09:13 PM
Last Post: nazmulfinance
  form.populate_obj problem "object has no attribute translate" pascale 0 1,996 Jun-12-2019, 07:30 PM
Last Post: pascale
  Error object has no attribute text hcyeap 3 10,619 May-21-2019, 07:12 AM
Last Post: buran
  AttributeError: 'dict' object has no attribute 'is_active' (PyMongo And Flask) usman 0 3,046 Nov-20-2018, 09:50 PM
Last Post: usman
  BeautifulSoup 'NoneType' object has no attribute 'text' bmccollum 9 10,478 Sep-14-2018, 12:56 PM
Last Post: bmccollum

Forum Jump:

User Panel Messages

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