{"action":"created","comment":{"url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/comments/42959063","id":42959063,"diff_hunk":"@@ -85,6 +85,10 @@ def outfile(seg_id):\n     # return io.open('{}/mapper-{:02}'.format( segdir, MAPPER_ID ), 'at', buffering=1, encoding=None)\n     return io.open('{}/mapper-{:02}'.format( segdir, MAPPER_ID ), 'wt', encoding = 'utf-8')\n \n+if sys.getdefaultencoding() != 'utf-8':\n+    reload(sys)\n+    sys.setdefaultencoding('utf-8')","path":"lmr","position":6,"original_position":6,"commit_id":"0bf6b12e9a8c8c9a98048c7e87f339c7a502dfb3","original_commit_id":"0bf6b12e9a8c8c9a98048c7e87f339c7a502dfb3","user":{"login":"dspp779","id":1401531,"avatar_url":"https://avatars.githubusercontent.com/u/1401531?v=3","gravatar_id":"","url":"https://api.github.com/users/dspp779","html_url":"https://github.com/dspp779","followers_url":"https://api.github.com/users/dspp779/followers","following_url":"https://api.github.com/users/dspp779/following{/other_user}","gists_url":"https://api.github.com/users/dspp779/gists{/gist_id}","starred_url":"https://api.github.com/users/dspp779/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dspp779/subscriptions","organizations_url":"https://api.github.com/users/dspp779/orgs","repos_url":"https://api.github.com/users/dspp779/repos","events_url":"https://api.github.com/users/dspp779/events{/privacy}","received_events_url":"https://api.github.com/users/dspp779/received_events","type":"User","site_admin":false},"body":"原始資料含 ascii 以外的字元，跑 lmr 會出現下面的錯誤\r\n```\r\nTraceback (most recent call last):\r\n  File \"dict.map.py\", line 40, in <module>\r\n    print '%s %s\\t%d %s' % (base, coll, bonus_dict[base], sent)\r\nUnicodeEncodeError: 'ascii' codec can't encode character u'\\u2212' in position 117: ordinal not in range(128)\r\n```\r\n輸出加上 encode 後，會出現下面的錯誤\r\n```\r\nTraceback (most recent call last):\r\n  File \"hashing.py.UYkj\", line 23, in <module>\r\n    key, _,value = line[:-1].partition('\\t')\r\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 117: ordinal not in range(128)\r\nTraceback (most recent call last):\r\n  File \"dict.map.py\", line 40, in <module>\r\n    print ('%s %s\\t%d %s' % (base, coll, bonus_dict[base], sent)).encode('utf-8')\r\n```\r\n一開始用 try except 包輸出的部分，出錯就不輸出，不過這樣就有一些資料被濾掉\r\n後來在 lmr 的 hashing 加上 utf8 的decode、encode 就可以跑，但py3的str沒有這東西\r\n試過 lmr 指令那邊用 python3，但這樣就一定要裝python3\r\n輸入資料在[ilms](http://lms.nthu.edu.tw/course.php?courseID=23571&f=doc&cid=801063)的sents.txt","created_at":"2015-10-26T04:20:27Z","updated_at":"2015-10-26T04:20:27Z","html_url":"https://github.com/d2207197/local-mapreduce/pull/1#discussion_r42959063","pull_request_url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/comments/42959063"},"html":{"href":"https://github.com/d2207197/local-mapreduce/pull/1#discussion_r42959063"},"pull_request":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1","id":48550613,"html_url":"https://github.com/d2207197/local-mapreduce/pull/1","diff_url":"https://github.com/d2207197/local-mapreduce/pull/1.diff","patch_url":"https://github.com/d2207197/local-mapreduce/pull/1.patch","issue_url":"https://api.github.com/repos/d2207197/local-mapreduce/issues/1","number":1,"state":"open","locked":false,"title":"fix py2 stdin encoding","user":{"login":"dspp779","id":1401531,"avatar_url":"https://avatars.githubusercontent.com/u/1401531?v=3","gravatar_id":"","url":"https://api.github.com/users/dspp779","html_url":"https://github.com/dspp779","followers_url":"https://api.github.com/users/dspp779/followers","following_url":"https://api.github.com/users/dspp779/following{/other_user}","gists_url":"https://api.github.com/users/dspp779/gists{/gist_id}","starred_url":"https://api.github.com/users/dspp779/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dspp779/subscriptions","organizations_url":"https://api.github.com/users/dspp779/orgs","repos_url":"https://api.github.com/users/dspp779/repos","events_url":"https://api.github.com/users/dspp779/events{/privacy}","received_events_url":"https://api.github.com/users/dspp779/received_events","type":"User","site_admin":false},"body":"UTF-8 stream causes problem in hashing.py under py2 while partitioning str objects from stdin. Set UTF-8 as default system encoding to read stream from stdin as unicode str.","created_at":"2015-10-23T07:44:34Z","updated_at":"2015-10-26T04:20:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0651a558b19d4d42fa689a9513eb85898fb932c4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1/commits","review_comments_url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1/comments","review_comment_url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/d2207197/local-mapreduce/issues/1/comments","statuses_url":"https://api.github.com/repos/d2207197/local-mapreduce/statuses/0bf6b12e9a8c8c9a98048c7e87f339c7a502dfb3","head":{"label":"dspp779:master","ref":"master","sha":"0bf6b12e9a8c8c9a98048c7e87f339c7a502dfb3","user":{"login":"dspp779","id":1401531,"avatar_url":"https://avatars.githubusercontent.com/u/1401531?v=3","gravatar_id":"","url":"https://api.github.com/users/dspp779","html_url":"https://github.com/dspp779","followers_url":"https://api.github.com/users/dspp779/followers","following_url":"https://api.github.com/users/dspp779/following{/other_user}","gists_url":"https://api.github.com/users/dspp779/gists{/gist_id}","starred_url":"https://api.github.com/users/dspp779/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dspp779/subscriptions","organizations_url":"https://api.github.com/users/dspp779/orgs","repos_url":"https://api.github.com/users/dspp779/repos","events_url":"https://api.github.com/users/dspp779/events{/privacy}","received_events_url":"https://api.github.com/users/dspp779/received_events","type":"User","site_admin":false},"repo":{"id":44738409,"name":"local-mapreduce","full_name":"dspp779/local-mapreduce","owner":{"login":"dspp779","id":1401531,"avatar_url":"https://avatars.githubusercontent.com/u/1401531?v=3","gravatar_id":"","url":"https://api.github.com/users/dspp779","html_url":"https://github.com/dspp779","followers_url":"https://api.github.com/users/dspp779/followers","following_url":"https://api.github.com/users/dspp779/following{/other_user}","gists_url":"https://api.github.com/users/dspp779/gists{/gist_id}","starred_url":"https://api.github.com/users/dspp779/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dspp779/subscriptions","organizations_url":"https://api.github.com/users/dspp779/orgs","repos_url":"https://api.github.com/users/dspp779/repos","events_url":"https://api.github.com/users/dspp779/events{/privacy}","received_events_url":"https://api.github.com/users/dspp779/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dspp779/local-mapreduce","description":"","fork":true,"url":"https://api.github.com/repos/dspp779/local-mapreduce","forks_url":"https://api.github.com/repos/dspp779/local-mapreduce/forks","keys_url":"https://api.github.com/repos/dspp779/local-mapreduce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dspp779/local-mapreduce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dspp779/local-mapreduce/teams","hooks_url":"https://api.github.com/repos/dspp779/local-mapreduce/hooks","issue_events_url":"https://api.github.com/repos/dspp779/local-mapreduce/issues/events{/number}","events_url":"https://api.github.com/repos/dspp779/local-mapreduce/events","assignees_url":"https://api.github.com/repos/dspp779/local-mapreduce/assignees{/user}","branches_url":"https://api.github.com/repos/dspp779/local-mapreduce/branches{/branch}","tags_url":"https://api.github.com/repos/dspp779/local-mapreduce/tags","blobs_url":"https://api.github.com/repos/dspp779/local-mapreduce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dspp779/local-mapreduce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dspp779/local-mapreduce/git/refs{/sha}","trees_url":"https://api.github.com/repos/dspp779/local-mapreduce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dspp779/local-mapreduce/statuses/{sha}","languages_url":"https://api.github.com/repos/dspp779/local-mapreduce/languages","stargazers_url":"https://api.github.com/repos/dspp779/local-mapreduce/stargazers","contributors_url":"https://api.github.com/repos/dspp779/local-mapreduce/contributors","subscribers_url":"https://api.github.com/repos/dspp779/local-mapreduce/subscribers","subscription_url":"https://api.github.com/repos/dspp779/local-mapreduce/subscription","commits_url":"https://api.github.com/repos/dspp779/local-mapreduce/commits{/sha}","git_commits_url":"https://api.github.com/repos/dspp779/local-mapreduce/git/commits{/sha}","comments_url":"https://api.github.com/repos/dspp779/local-mapreduce/comments{/number}","issue_comment_url":"https://api.github.com/repos/dspp779/local-mapreduce/issues/comments{/number}","contents_url":"https://api.github.com/repos/dspp779/local-mapreduce/contents/{+path}","compare_url":"https://api.github.com/repos/dspp779/local-mapreduce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dspp779/local-mapreduce/merges","archive_url":"https://api.github.com/repos/dspp779/local-mapreduce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dspp779/local-mapreduce/downloads","issues_url":"https://api.github.com/repos/dspp779/local-mapreduce/issues{/number}","pulls_url":"https://api.github.com/repos/dspp779/local-mapreduce/pulls{/number}","milestones_url":"https://api.github.com/repos/dspp779/local-mapreduce/milestones{/number}","notifications_url":"https://api.github.com/repos/dspp779/local-mapreduce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dspp779/local-mapreduce/labels{/name}","releases_url":"https://api.github.com/repos/dspp779/local-mapreduce/releases{/id}","created_at":"2015-10-22T10:29:45Z","updated_at":"2015-10-22T10:29:55Z","pushed_at":"2015-10-23T07:29:55Z","git_url":"git://github.com/dspp779/local-mapreduce.git","ssh_url":"git@github.com:dspp779/local-mapreduce.git","clone_url":"https://github.com/dspp779/local-mapreduce.git","svn_url":"https://github.com/dspp779/local-mapreduce","homepage":"","size":107,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"d2207197:master","ref":"master","sha":"b1c567391ceaf90cecdb1a81889a139277e50b1d","user":{"login":"d2207197","id":73888,"avatar_url":"https://avatars.githubusercontent.com/u/73888?v=3","gravatar_id":"","url":"https://api.github.com/users/d2207197","html_url":"https://github.com/d2207197","followers_url":"https://api.github.com/users/d2207197/followers","following_url":"https://api.github.com/users/d2207197/following{/other_user}","gists_url":"https://api.github.com/users/d2207197/gists{/gist_id}","starred_url":"https://api.github.com/users/d2207197/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d2207197/subscriptions","organizations_url":"https://api.github.com/users/d2207197/orgs","repos_url":"https://api.github.com/users/d2207197/repos","events_url":"https://api.github.com/users/d2207197/events{/privacy}","received_events_url":"https://api.github.com/users/d2207197/received_events","type":"User","site_admin":false},"repo":{"id":26324520,"name":"local-mapreduce","full_name":"d2207197/local-mapreduce","owner":{"login":"d2207197","id":73888,"avatar_url":"https://avatars.githubusercontent.com/u/73888?v=3","gravatar_id":"","url":"https://api.github.com/users/d2207197","html_url":"https://github.com/d2207197","followers_url":"https://api.github.com/users/d2207197/followers","following_url":"https://api.github.com/users/d2207197/following{/other_user}","gists_url":"https://api.github.com/users/d2207197/gists{/gist_id}","starred_url":"https://api.github.com/users/d2207197/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d2207197/subscriptions","organizations_url":"https://api.github.com/users/d2207197/orgs","repos_url":"https://api.github.com/users/d2207197/repos","events_url":"https://api.github.com/users/d2207197/events{/privacy}","received_events_url":"https://api.github.com/users/d2207197/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/d2207197/local-mapreduce","description":null,"fork":false,"url":"https://api.github.com/repos/d2207197/local-mapreduce","forks_url":"https://api.github.com/repos/d2207197/local-mapreduce/forks","keys_url":"https://api.github.com/repos/d2207197/local-mapreduce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/d2207197/local-mapreduce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/d2207197/local-mapreduce/teams","hooks_url":"https://api.github.com/repos/d2207197/local-mapreduce/hooks","issue_events_url":"https://api.github.com/repos/d2207197/local-mapreduce/issues/events{/number}","events_url":"https://api.github.com/repos/d2207197/local-mapreduce/events","assignees_url":"https://api.github.com/repos/d2207197/local-mapreduce/assignees{/user}","branches_url":"https://api.github.com/repos/d2207197/local-mapreduce/branches{/branch}","tags_url":"https://api.github.com/repos/d2207197/local-mapreduce/tags","blobs_url":"https://api.github.com/repos/d2207197/local-mapreduce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/d2207197/local-mapreduce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/d2207197/local-mapreduce/git/refs{/sha}","trees_url":"https://api.github.com/repos/d2207197/local-mapreduce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/d2207197/local-mapreduce/statuses/{sha}","languages_url":"https://api.github.com/repos/d2207197/local-mapreduce/languages","stargazers_url":"https://api.github.com/repos/d2207197/local-mapreduce/stargazers","contributors_url":"https://api.github.com/repos/d2207197/local-mapreduce/contributors","subscribers_url":"https://api.github.com/repos/d2207197/local-mapreduce/subscribers","subscription_url":"https://api.github.com/repos/d2207197/local-mapreduce/subscription","commits_url":"https://api.github.com/repos/d2207197/local-mapreduce/commits{/sha}","git_commits_url":"https://api.github.com/repos/d2207197/local-mapreduce/git/commits{/sha}","comments_url":"https://api.github.com/repos/d2207197/local-mapreduce/comments{/number}","issue_comment_url":"https://api.github.com/repos/d2207197/local-mapreduce/issues/comments{/number}","contents_url":"https://api.github.com/repos/d2207197/local-mapreduce/contents/{+path}","compare_url":"https://api.github.com/repos/d2207197/local-mapreduce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/d2207197/local-mapreduce/merges","archive_url":"https://api.github.com/repos/d2207197/local-mapreduce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/d2207197/local-mapreduce/downloads","issues_url":"https://api.github.com/repos/d2207197/local-mapreduce/issues{/number}","pulls_url":"https://api.github.com/repos/d2207197/local-mapreduce/pulls{/number}","milestones_url":"https://api.github.com/repos/d2207197/local-mapreduce/milestones{/number}","notifications_url":"https://api.github.com/repos/d2207197/local-mapreduce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/d2207197/local-mapreduce/labels{/name}","releases_url":"https://api.github.com/repos/d2207197/local-mapreduce/releases{/id}","created_at":"2014-11-07T15:07:51Z","updated_at":"2015-10-22T10:29:18Z","pushed_at":"2015-10-23T07:44:35Z","git_url":"git://github.com/d2207197/local-mapreduce.git","ssh_url":"git@github.com:d2207197/local-mapreduce.git","clone_url":"https://github.com/d2207197/local-mapreduce.git","svn_url":"https://github.com/d2207197/local-mapreduce","homepage":null,"size":166,"stargazers_count":4,"watchers_count":4,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1"},"html":{"href":"https://github.com/d2207197/local-mapreduce/pull/1"},"issue":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/issues/1"},"comments":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/d2207197/local-mapreduce/statuses/0bf6b12e9a8c8c9a98048c7e87f339c7a502dfb3"}}}}