{"action":"created","comment":{"url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/comments/25143628","id":25143628,"diff_hunk":"@@ -0,0 +1,116 @@\n+package nearsoft.academy.bigdata.recommendation;\n+\n+import java.io.BufferedReader;\n+import java.io.FileInputStream;\n+import java.io.IOException;\n+import java.io.InputStreamReader;\n+import java.util.zip.GZIPInputStream;\n+import java.io.BufferedWriter;\n+import java.io.File;\n+import java.io.FileWriter;\n+import org.apache.mahout.cf.taste.common.TasteException;\n+import org.apache.mahout.cf.taste.impl.model.MemoryIDMigrator;\n+ \n+public class TextReducer {\n+    private BufferedWriter writer = null;\n+    private MemoryIDMigrator memoryIDMigrator;\n+    private String path;\n+    private int numberOfLines = 0;\n+    public TextReducer(String path , MemoryIDMigrator m)\n+    {\n+        this.path = path;\n+        memoryIDMigrator = m;\n+    }\n+    //creates a file named temp.csv where everythins is parsed and processed as Mahout wants\n+    public void clean() throws IOException\n+    {\n+        //read the input of the file\n+        FileInputStream fin = new FileInputStream(path);\n+        GZIPInputStream gzis = new GZIPInputStream(fin);\n+        InputStreamReader xover = new InputStreamReader(gzis);\n+        BufferedReader is = new BufferedReader(xover);\n+     \n+        //write the output of the file\n+        String line,currentBlock=\"\";\n+        File logFile = new File(\"temp.csv\");\n+        writer = new BufferedWriter(new FileWriter(logFile));\n+        //int index_line = 0;\n+        //process and transform it\n+        line = is.readLine();\n+        while (line != null ){\n+            //first line is product ID\n+            String productId = substr(line, ':');\n+            line = is.readLine();\n+            //second line is user ID\n+            String userId = substr(line, ':');\n+            line = is.readLine();\n+\n+            //read until score's line\n+            while(line == null || line.equals(\"\") || !line.matches(\"^review/score(.*)\"))\n+                line = is.readLine();\n+\n+\n+            if(line == null || line.equals(\"\") || !line.matches(\"^review/score(.*)\")) //there was no score\n+            {\n+                while(line == null || !line.equals(\"\"))\n+                    line = is.readLine();\n+                continue;\n+            }\n+            //the curret line is the score\n+            String score = substr(line, ':');\n+            //store to file\n+            //<thread> if possible\n+            cleanBlock(userId, productId, score);\n+            //</thread>\n+            //read until next paragraph\n+            while(line == null || !line.equals(\"\"))\n+                line = is.readLine();\n+\n+            //read the next line (should be the product id or null)\n+            line = is.readLine();\n+        }\n+        is.close();\n+        writer.close();\n+        \n+    }\n+\n+    // clean the file\n+    private void cleanBlock(String userId, String productId, String score) throws IOException","path":"src/test/java/nearsoft/academy/bigdata/recommendation/TextReducer.java","position":78,"original_position":78,"commit_id":"bf6e4a448b8065d64b1903bf2545e5ffeb77fb59","original_commit_id":"bf6e4a448b8065d64b1903bf2545e5ffeb77fb59","user":{"login":"rilopez","id":781860,"avatar_url":"https://avatars.githubusercontent.com/u/781860?v=3","gravatar_id":"","url":"https://api.github.com/users/rilopez","html_url":"https://github.com/rilopez","followers_url":"https://api.github.com/users/rilopez/followers","following_url":"https://api.github.com/users/rilopez/following{/other_user}","gists_url":"https://api.github.com/users/rilopez/gists{/gist_id}","starred_url":"https://api.github.com/users/rilopez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilopez/subscriptions","organizations_url":"https://api.github.com/users/rilopez/orgs","repos_url":"https://api.github.com/users/rilopez/repos","events_url":"https://api.github.com/users/rilopez/events{/privacy}","received_events_url":"https://api.github.com/users/rilopez/received_events","type":"User","site_admin":false},"body":"1 ) this should have a better name , cleanBlock is not descritive \r\n2) it seems that its doing too much (writing a comma separated line, mapping the ids, incrementing the counters) ","created_at":"2015-02-23T04:35:42Z","updated_at":"2015-02-23T04:35:42Z","html_url":"https://github.com/rilopez/big-data-exercises/pull/1#discussion_r25143628","pull_request_url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/comments/25143628"},"html":{"href":"https://github.com/rilopez/big-data-exercises/pull/1#discussion_r25143628"},"pull_request":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1","id":29739262,"html_url":"https://github.com/rilopez/big-data-exercises/pull/1","diff_url":"https://github.com/rilopez/big-data-exercises/pull/1.diff","patch_url":"https://github.com/rilopez/big-data-exercises/pull/1.patch","issue_url":"https://api.github.com/repos/rilopez/big-data-exercises/issues/1","number":1,"state":"open","locked":false,"title":"Big Data Solution Nearsoft Academy","user":{"login":"pmduaree","id":10998479,"avatar_url":"https://avatars.githubusercontent.com/u/10998479?v=3","gravatar_id":"","url":"https://api.github.com/users/pmduaree","html_url":"https://github.com/pmduaree","followers_url":"https://api.github.com/users/pmduaree/followers","following_url":"https://api.github.com/users/pmduaree/following{/other_user}","gists_url":"https://api.github.com/users/pmduaree/gists{/gist_id}","starred_url":"https://api.github.com/users/pmduaree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmduaree/subscriptions","organizations_url":"https://api.github.com/users/pmduaree/orgs","repos_url":"https://api.github.com/users/pmduaree/repos","events_url":"https://api.github.com/users/pmduaree/events{/privacy}","received_events_url":"https://api.github.com/users/pmduaree/received_events","type":"User","site_admin":false},"body":"Here is the solution of the big data problem made by the intern's team.\r\nThe program takes 9 minutes cleaning the file and the recommendations.\r\n\r\n-Interns","created_at":"2015-02-20T23:03:22Z","updated_at":"2015-02-23T04:35:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"063efa6068879d43d85a1b89aa6143f7a8c1514c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1/commits","review_comments_url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1/comments","review_comment_url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rilopez/big-data-exercises/issues/1/comments","statuses_url":"https://api.github.com/repos/rilopez/big-data-exercises/statuses/bf6e4a448b8065d64b1903bf2545e5ffeb77fb59","head":{"label":"pmduaree:master","ref":"master","sha":"bf6e4a448b8065d64b1903bf2545e5ffeb77fb59","user":{"login":"pmduaree","id":10998479,"avatar_url":"https://avatars.githubusercontent.com/u/10998479?v=3","gravatar_id":"","url":"https://api.github.com/users/pmduaree","html_url":"https://github.com/pmduaree","followers_url":"https://api.github.com/users/pmduaree/followers","following_url":"https://api.github.com/users/pmduaree/following{/other_user}","gists_url":"https://api.github.com/users/pmduaree/gists{/gist_id}","starred_url":"https://api.github.com/users/pmduaree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmduaree/subscriptions","organizations_url":"https://api.github.com/users/pmduaree/orgs","repos_url":"https://api.github.com/users/pmduaree/repos","events_url":"https://api.github.com/users/pmduaree/events{/privacy}","received_events_url":"https://api.github.com/users/pmduaree/received_events","type":"User","site_admin":false},"repo":{"id":31045419,"name":"big-data-exercises","full_name":"pmduaree/big-data-exercises","owner":{"login":"pmduaree","id":10998479,"avatar_url":"https://avatars.githubusercontent.com/u/10998479?v=3","gravatar_id":"","url":"https://api.github.com/users/pmduaree","html_url":"https://github.com/pmduaree","followers_url":"https://api.github.com/users/pmduaree/followers","following_url":"https://api.github.com/users/pmduaree/following{/other_user}","gists_url":"https://api.github.com/users/pmduaree/gists{/gist_id}","starred_url":"https://api.github.com/users/pmduaree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmduaree/subscriptions","organizations_url":"https://api.github.com/users/pmduaree/orgs","repos_url":"https://api.github.com/users/pmduaree/repos","events_url":"https://api.github.com/users/pmduaree/events{/privacy}","received_events_url":"https://api.github.com/users/pmduaree/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pmduaree/big-data-exercises","description":"","fork":true,"url":"https://api.github.com/repos/pmduaree/big-data-exercises","forks_url":"https://api.github.com/repos/pmduaree/big-data-exercises/forks","keys_url":"https://api.github.com/repos/pmduaree/big-data-exercises/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pmduaree/big-data-exercises/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pmduaree/big-data-exercises/teams","hooks_url":"https://api.github.com/repos/pmduaree/big-data-exercises/hooks","issue_events_url":"https://api.github.com/repos/pmduaree/big-data-exercises/issues/events{/number}","events_url":"https://api.github.com/repos/pmduaree/big-data-exercises/events","assignees_url":"https://api.github.com/repos/pmduaree/big-data-exercises/assignees{/user}","branches_url":"https://api.github.com/repos/pmduaree/big-data-exercises/branches{/branch}","tags_url":"https://api.github.com/repos/pmduaree/big-data-exercises/tags","blobs_url":"https://api.github.com/repos/pmduaree/big-data-exercises/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pmduaree/big-data-exercises/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pmduaree/big-data-exercises/git/refs{/sha}","trees_url":"https://api.github.com/repos/pmduaree/big-data-exercises/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pmduaree/big-data-exercises/statuses/{sha}","languages_url":"https://api.github.com/repos/pmduaree/big-data-exercises/languages","stargazers_url":"https://api.github.com/repos/pmduaree/big-data-exercises/stargazers","contributors_url":"https://api.github.com/repos/pmduaree/big-data-exercises/contributors","subscribers_url":"https://api.github.com/repos/pmduaree/big-data-exercises/subscribers","subscription_url":"https://api.github.com/repos/pmduaree/big-data-exercises/subscription","commits_url":"https://api.github.com/repos/pmduaree/big-data-exercises/commits{/sha}","git_commits_url":"https://api.github.com/repos/pmduaree/big-data-exercises/git/commits{/sha}","comments_url":"https://api.github.com/repos/pmduaree/big-data-exercises/comments{/number}","issue_comment_url":"https://api.github.com/repos/pmduaree/big-data-exercises/issues/comments{/number}","contents_url":"https://api.github.com/repos/pmduaree/big-data-exercises/contents/{+path}","compare_url":"https://api.github.com/repos/pmduaree/big-data-exercises/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pmduaree/big-data-exercises/merges","archive_url":"https://api.github.com/repos/pmduaree/big-data-exercises/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pmduaree/big-data-exercises/downloads","issues_url":"https://api.github.com/repos/pmduaree/big-data-exercises/issues{/number}","pulls_url":"https://api.github.com/repos/pmduaree/big-data-exercises/pulls{/number}","milestones_url":"https://api.github.com/repos/pmduaree/big-data-exercises/milestones{/number}","notifications_url":"https://api.github.com/repos/pmduaree/big-data-exercises/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pmduaree/big-data-exercises/labels{/name}","releases_url":"https://api.github.com/repos/pmduaree/big-data-exercises/releases{/id}","created_at":"2015-02-20T00:57:48Z","updated_at":"2015-02-20T22:45:20Z","pushed_at":"2015-02-20T22:45:20Z","git_url":"git://github.com/pmduaree/big-data-exercises.git","ssh_url":"git@github.com:pmduaree/big-data-exercises.git","clone_url":"https://github.com/pmduaree/big-data-exercises.git","svn_url":"https://github.com/pmduaree/big-data-exercises","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"rilopez:master","ref":"master","sha":"2a258f366668e0ba286d37250e7dff6930993b27","user":{"login":"rilopez","id":781860,"avatar_url":"https://avatars.githubusercontent.com/u/781860?v=3","gravatar_id":"","url":"https://api.github.com/users/rilopez","html_url":"https://github.com/rilopez","followers_url":"https://api.github.com/users/rilopez/followers","following_url":"https://api.github.com/users/rilopez/following{/other_user}","gists_url":"https://api.github.com/users/rilopez/gists{/gist_id}","starred_url":"https://api.github.com/users/rilopez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilopez/subscriptions","organizations_url":"https://api.github.com/users/rilopez/orgs","repos_url":"https://api.github.com/users/rilopez/repos","events_url":"https://api.github.com/users/rilopez/events{/privacy}","received_events_url":"https://api.github.com/users/rilopez/received_events","type":"User","site_admin":false},"repo":{"id":30854339,"name":"big-data-exercises","full_name":"rilopez/big-data-exercises","owner":{"login":"rilopez","id":781860,"avatar_url":"https://avatars.githubusercontent.com/u/781860?v=3","gravatar_id":"","url":"https://api.github.com/users/rilopez","html_url":"https://github.com/rilopez","followers_url":"https://api.github.com/users/rilopez/followers","following_url":"https://api.github.com/users/rilopez/following{/other_user}","gists_url":"https://api.github.com/users/rilopez/gists{/gist_id}","starred_url":"https://api.github.com/users/rilopez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilopez/subscriptions","organizations_url":"https://api.github.com/users/rilopez/orgs","repos_url":"https://api.github.com/users/rilopez/repos","events_url":"https://api.github.com/users/rilopez/events{/privacy}","received_events_url":"https://api.github.com/users/rilopez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rilopez/big-data-exercises","description":"","fork":false,"url":"https://api.github.com/repos/rilopez/big-data-exercises","forks_url":"https://api.github.com/repos/rilopez/big-data-exercises/forks","keys_url":"https://api.github.com/repos/rilopez/big-data-exercises/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rilopez/big-data-exercises/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rilopez/big-data-exercises/teams","hooks_url":"https://api.github.com/repos/rilopez/big-data-exercises/hooks","issue_events_url":"https://api.github.com/repos/rilopez/big-data-exercises/issues/events{/number}","events_url":"https://api.github.com/repos/rilopez/big-data-exercises/events","assignees_url":"https://api.github.com/repos/rilopez/big-data-exercises/assignees{/user}","branches_url":"https://api.github.com/repos/rilopez/big-data-exercises/branches{/branch}","tags_url":"https://api.github.com/repos/rilopez/big-data-exercises/tags","blobs_url":"https://api.github.com/repos/rilopez/big-data-exercises/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rilopez/big-data-exercises/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rilopez/big-data-exercises/git/refs{/sha}","trees_url":"https://api.github.com/repos/rilopez/big-data-exercises/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rilopez/big-data-exercises/statuses/{sha}","languages_url":"https://api.github.com/repos/rilopez/big-data-exercises/languages","stargazers_url":"https://api.github.com/repos/rilopez/big-data-exercises/stargazers","contributors_url":"https://api.github.com/repos/rilopez/big-data-exercises/contributors","subscribers_url":"https://api.github.com/repos/rilopez/big-data-exercises/subscribers","subscription_url":"https://api.github.com/repos/rilopez/big-data-exercises/subscription","commits_url":"https://api.github.com/repos/rilopez/big-data-exercises/commits{/sha}","git_commits_url":"https://api.github.com/repos/rilopez/big-data-exercises/git/commits{/sha}","comments_url":"https://api.github.com/repos/rilopez/big-data-exercises/comments{/number}","issue_comment_url":"https://api.github.com/repos/rilopez/big-data-exercises/issues/comments{/number}","contents_url":"https://api.github.com/repos/rilopez/big-data-exercises/contents/{+path}","compare_url":"https://api.github.com/repos/rilopez/big-data-exercises/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rilopez/big-data-exercises/merges","archive_url":"https://api.github.com/repos/rilopez/big-data-exercises/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rilopez/big-data-exercises/downloads","issues_url":"https://api.github.com/repos/rilopez/big-data-exercises/issues{/number}","pulls_url":"https://api.github.com/repos/rilopez/big-data-exercises/pulls{/number}","milestones_url":"https://api.github.com/repos/rilopez/big-data-exercises/milestones{/number}","notifications_url":"https://api.github.com/repos/rilopez/big-data-exercises/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rilopez/big-data-exercises/labels{/name}","releases_url":"https://api.github.com/repos/rilopez/big-data-exercises/releases{/id}","created_at":"2015-02-16T04:53:11Z","updated_at":"2015-02-16T15:34:43Z","pushed_at":"2015-02-16T15:34:43Z","git_url":"git://github.com/rilopez/big-data-exercises.git","ssh_url":"git@github.com:rilopez/big-data-exercises.git","clone_url":"https://github.com/rilopez/big-data-exercises.git","svn_url":"https://github.com/rilopez/big-data-exercises","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1"},"html":{"href":"https://github.com/rilopez/big-data-exercises/pull/1"},"issue":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/issues/1"},"comments":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/rilopez/big-data-exercises/statuses/bf6e4a448b8065d64b1903bf2545e5ffeb77fb59"}}}}