{"action":"created","comment":{"url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/comments/43718786","id":43718786,"diff_hunk":"@@ -0,0 +1,124 @@\n+'''\n+#-------------------------------------------------#\n+# Title: kata\n+# Dev:   Marty Pitts\n+# Date:  Nov 1, 2015\n+# Desc:\n+\n+Look at each set of three adjacent words in a document. Use the first two words\n+of the set as a key, and remember the fact that the third word followed that key.\n+Once finished, you know the list of individual words that can follow each\n+In:\n+I wish I may I wish I might\n+\n+Out:\n+\"I wish\" => [\"I\", \"I\"]\n+\"wish I\" => [\"may\", \"might\"]\n+\"may I\"  => [\"wish\"]\n+\"I may\"  => [\"I\"]\n+\n+To generate new text from this analysis, choose an arbitrary word pair as a\n+starting point. Use these to look up a random next word (using the table above)\n+and append this new word to the text so far. This now gives you a new word pair\n+at the end of the text, so look up a potential next word based on these. Add this\n+to the list, and so on. In the previous example, we could start with (I may). The\n+'''\n+\n+# -----  Data Code ------\n+objFileNameRead = \"sherlock.txt\"\n+objFileNameWrite = \"mystory.txt\"\n+KataDict = {}\n+StoryDict = {}\n+StorySeedKey = \"his every\"\n+StorySeedNew = \"long they\"\n+StorySeedNew2 = \"while the\"\n+\n+StorySize = 100\n+\n+#  -- processing code --\n+#  Create functions to do the following.\n+'''\n+1) Open a file from a prior book.\n+2) Build a dictionary using first two words as key and third as data item.\n+3) Merge the dictionary items into a list with first item key followed by merged data items.\n+4) Querry input for two words to build 200 word story.\n+'''\n+\n+\n+def BuildDict(objFileNameRead):\n+    ''' Build a dictionary from a file. Use the first two words as key and third element as data. '''\n+    WordList = []\n+    CleanWordList = []\n+\n+    # OPen the file and read a line\n+    objFile = open(objFileNameRead, \"r\")\n+    FileIn = objFile.read()\n+\n+    # Dump the line to a list\n+    WordList = FileIn.split(' ')\n+\n+    # Remove Characters I do not want in dictionary\n+    CleanWordList = ([s.replace('-',' ') for s in WordList])\n+    # CleanWordList = ([s.replace(' ','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('\\n','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('(','') for s in CleanWordList])\n+    CleanWordList = ([s.replace(')','') for s in CleanWordList])\n+\n+    CleanWordList = ([s.replace('1','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('2','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('3','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('4','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('5','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('6','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('7','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('8','') for s in CleanWordList])\n+    CleanWordList = ([s.replace('9','') for s in CleanWordList])\n+    print(\"Clean Word List =\", CleanWordList)\n+\n+    # Build a Dictionary\n+    DictPointer = 0\n+    for items in CleanWordList:\n+        if DictPointer < len(CleanWordList) - 4:\n+            CleanWordList[DictPointer] = (CleanWordList[DictPointer] + ' ')\n+            KeyIn = ''.join(CleanWordList[DictPointer:DictPointer+2])\n+            DataIn = CleanWordList[DictPointer+2]\n+            KataDict.update({KeyIn : DataIn})\n+            DictPointer = DictPointer + 1\n+        else: break\n+    # End For\n+    # print(\"Dictionary = \", KataDict)\n+    return(KataDict)\n+","path":"students/martypitts/session04/kata.py","position":91,"original_position":91,"commit_id":"5265721d31f54aeceb43ac3ecd83890d75bc9489","original_commit_id":"5265721d31f54aeceb43ac3ecd83890d75bc9489","user":{"login":"PythonCHB","id":1840917,"avatar_url":"https://avatars.githubusercontent.com/u/1840917?v=3","gravatar_id":"","url":"https://api.github.com/users/PythonCHB","html_url":"https://github.com/PythonCHB","followers_url":"https://api.github.com/users/PythonCHB/followers","following_url":"https://api.github.com/users/PythonCHB/following{/other_user}","gists_url":"https://api.github.com/users/PythonCHB/gists{/gist_id}","starred_url":"https://api.github.com/users/PythonCHB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PythonCHB/subscriptions","organizations_url":"https://api.github.com/users/PythonCHB/orgs","repos_url":"https://api.github.com/users/PythonCHB/repos","events_url":"https://api.github.com/users/PythonCHB/events{/privacy}","received_events_url":"https://api.github.com/users/PythonCHB/received_events","type":"User","site_admin":false},"body":"but a bit of a gap in the logic: the same pair of words appears more than once -- the idea is that you want to keep track of all the possible words that follow a given pair. Then when you built text from that, you can randomly select which following word to use.","created_at":"2015-11-03T06:09:31Z","updated_at":"2015-11-03T06:09:31Z","html_url":"https://github.com/UWPCE-PythonCert/IntroPython2015/pull/75#discussion_r43718786","pull_request_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75","_links":{"self":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/comments/43718786"},"html":{"href":"https://github.com/UWPCE-PythonCert/IntroPython2015/pull/75#discussion_r43718786"},"pull_request":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75"}}},"pull_request":{"url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75","id":49517115,"html_url":"https://github.com/UWPCE-PythonCert/IntroPython2015/pull/75","diff_url":"https://github.com/UWPCE-PythonCert/IntroPython2015/pull/75.diff","patch_url":"https://github.com/UWPCE-PythonCert/IntroPython2015/pull/75.patch","issue_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues/75","number":75,"state":"open","locked":false,"title":"Session04 lab","user":{"login":"mdpitts2000","id":15116445,"avatar_url":"https://avatars.githubusercontent.com/u/15116445?v=3","gravatar_id":"","url":"https://api.github.com/users/mdpitts2000","html_url":"https://github.com/mdpitts2000","followers_url":"https://api.github.com/users/mdpitts2000/followers","following_url":"https://api.github.com/users/mdpitts2000/following{/other_user}","gists_url":"https://api.github.com/users/mdpitts2000/gists{/gist_id}","starred_url":"https://api.github.com/users/mdpitts2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdpitts2000/subscriptions","organizations_url":"https://api.github.com/users/mdpitts2000/orgs","repos_url":"https://api.github.com/users/mdpitts2000/repos","events_url":"https://api.github.com/users/mdpitts2000/events{/privacy}","received_events_url":"https://api.github.com/users/mdpitts2000/received_events","type":"User","site_admin":false},"body":"Session 04 lab","created_at":"2015-11-03T03:50:46Z","updated_at":"2015-11-03T06:09:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d4189d20088d394b8770a94733a53d0ca11a779","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75/commits","review_comments_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75/comments","review_comment_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues/75/comments","statuses_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/statuses/5265721d31f54aeceb43ac3ecd83890d75bc9489","head":{"label":"mdpitts2000:master","ref":"master","sha":"5265721d31f54aeceb43ac3ecd83890d75bc9489","user":{"login":"mdpitts2000","id":15116445,"avatar_url":"https://avatars.githubusercontent.com/u/15116445?v=3","gravatar_id":"","url":"https://api.github.com/users/mdpitts2000","html_url":"https://github.com/mdpitts2000","followers_url":"https://api.github.com/users/mdpitts2000/followers","following_url":"https://api.github.com/users/mdpitts2000/following{/other_user}","gists_url":"https://api.github.com/users/mdpitts2000/gists{/gist_id}","starred_url":"https://api.github.com/users/mdpitts2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdpitts2000/subscriptions","organizations_url":"https://api.github.com/users/mdpitts2000/orgs","repos_url":"https://api.github.com/users/mdpitts2000/repos","events_url":"https://api.github.com/users/mdpitts2000/events{/privacy}","received_events_url":"https://api.github.com/users/mdpitts2000/received_events","type":"User","site_admin":false},"repo":{"id":44216532,"name":"IntroPython2015","full_name":"mdpitts2000/IntroPython2015","owner":{"login":"mdpitts2000","id":15116445,"avatar_url":"https://avatars.githubusercontent.com/u/15116445?v=3","gravatar_id":"","url":"https://api.github.com/users/mdpitts2000","html_url":"https://github.com/mdpitts2000","followers_url":"https://api.github.com/users/mdpitts2000/followers","following_url":"https://api.github.com/users/mdpitts2000/following{/other_user}","gists_url":"https://api.github.com/users/mdpitts2000/gists{/gist_id}","starred_url":"https://api.github.com/users/mdpitts2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdpitts2000/subscriptions","organizations_url":"https://api.github.com/users/mdpitts2000/orgs","repos_url":"https://api.github.com/users/mdpitts2000/repos","events_url":"https://api.github.com/users/mdpitts2000/events{/privacy}","received_events_url":"https://api.github.com/users/mdpitts2000/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mdpitts2000/IntroPython2015","description":"","fork":true,"url":"https://api.github.com/repos/mdpitts2000/IntroPython2015","forks_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/forks","keys_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/teams","hooks_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/hooks","issue_events_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/issues/events{/number}","events_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/events","assignees_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/assignees{/user}","branches_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/branches{/branch}","tags_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/tags","blobs_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/statuses/{sha}","languages_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/languages","stargazers_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/stargazers","contributors_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/contributors","subscribers_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/subscribers","subscription_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/subscription","commits_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/contents/{+path}","compare_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/merges","archive_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/downloads","issues_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/issues{/number}","pulls_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/pulls{/number}","milestones_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/milestones{/number}","notifications_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/labels{/name}","releases_url":"https://api.github.com/repos/mdpitts2000/IntroPython2015/releases{/id}","created_at":"2015-10-14T01:31:40Z","updated_at":"2015-10-19T03:13:47Z","pushed_at":"2015-11-03T03:47:35Z","git_url":"git://github.com/mdpitts2000/IntroPython2015.git","ssh_url":"git@github.com:mdpitts2000/IntroPython2015.git","clone_url":"https://github.com/mdpitts2000/IntroPython2015.git","svn_url":"https://github.com/mdpitts2000/IntroPython2015","homepage":null,"size":493,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"UWPCE-PythonCert:master","ref":"master","sha":"44e300c0ab5f017cfdb9c78af919ebea256ab9a0","user":{"login":"UWPCE-PythonCert","id":5218825,"avatar_url":"https://avatars.githubusercontent.com/u/5218825?v=3","gravatar_id":"","url":"https://api.github.com/users/UWPCE-PythonCert","html_url":"https://github.com/UWPCE-PythonCert","followers_url":"https://api.github.com/users/UWPCE-PythonCert/followers","following_url":"https://api.github.com/users/UWPCE-PythonCert/following{/other_user}","gists_url":"https://api.github.com/users/UWPCE-PythonCert/gists{/gist_id}","starred_url":"https://api.github.com/users/UWPCE-PythonCert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UWPCE-PythonCert/subscriptions","organizations_url":"https://api.github.com/users/UWPCE-PythonCert/orgs","repos_url":"https://api.github.com/users/UWPCE-PythonCert/repos","events_url":"https://api.github.com/users/UWPCE-PythonCert/events{/privacy}","received_events_url":"https://api.github.com/users/UWPCE-PythonCert/received_events","type":"Organization","site_admin":false},"repo":{"id":44215972,"name":"IntroPython2015","full_name":"UWPCE-PythonCert/IntroPython2015","owner":{"login":"UWPCE-PythonCert","id":5218825,"avatar_url":"https://avatars.githubusercontent.com/u/5218825?v=3","gravatar_id":"","url":"https://api.github.com/users/UWPCE-PythonCert","html_url":"https://github.com/UWPCE-PythonCert","followers_url":"https://api.github.com/users/UWPCE-PythonCert/followers","following_url":"https://api.github.com/users/UWPCE-PythonCert/following{/other_user}","gists_url":"https://api.github.com/users/UWPCE-PythonCert/gists{/gist_id}","starred_url":"https://api.github.com/users/UWPCE-PythonCert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UWPCE-PythonCert/subscriptions","organizations_url":"https://api.github.com/users/UWPCE-PythonCert/orgs","repos_url":"https://api.github.com/users/UWPCE-PythonCert/repos","events_url":"https://api.github.com/users/UWPCE-PythonCert/events{/privacy}","received_events_url":"https://api.github.com/users/UWPCE-PythonCert/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UWPCE-PythonCert/IntroPython2015","description":"","fork":false,"url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015","forks_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/forks","keys_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/teams","hooks_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/hooks","issue_events_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues/events{/number}","events_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/events","assignees_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/assignees{/user}","branches_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/branches{/branch}","tags_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/tags","blobs_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/git/refs{/sha}","trees_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/statuses/{sha}","languages_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/languages","stargazers_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/stargazers","contributors_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/contributors","subscribers_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/subscribers","subscription_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/subscription","commits_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/commits{/sha}","git_commits_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/git/commits{/sha}","comments_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/comments{/number}","issue_comment_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues/comments{/number}","contents_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/contents/{+path}","compare_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/merges","archive_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/downloads","issues_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues{/number}","pulls_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls{/number}","milestones_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/milestones{/number}","notifications_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/labels{/name}","releases_url":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/releases{/id}","created_at":"2015-10-14T01:21:03Z","updated_at":"2015-10-14T03:12:26Z","pushed_at":"2015-11-03T05:09:06Z","git_url":"git://github.com/UWPCE-PythonCert/IntroPython2015.git","ssh_url":"git@github.com:UWPCE-PythonCert/IntroPython2015.git","clone_url":"https://github.com/UWPCE-PythonCert/IntroPython2015.git","svn_url":"https://github.com/UWPCE-PythonCert/IntroPython2015","homepage":null,"size":1448,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":2,"forks":24,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75"},"html":{"href":"https://github.com/UWPCE-PythonCert/IntroPython2015/pull/75"},"issue":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues/75"},"comments":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/issues/75/comments"},"review_comments":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75/comments"},"review_comment":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/pulls/75/commits"},"statuses":{"href":"https://api.github.com/repos/UWPCE-PythonCert/IntroPython2015/statuses/5265721d31f54aeceb43ac3ecd83890d75bc9489"}}}}