{"action":"created","comment":{"url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/comments/88803433","pull_request_review_id":9366185,"id":88803433,"diff_hunk":"@@ -0,0 +1,123 @@\n+//Inverted index class to hold all functionalities expected\n+class InvertedIndex{\n+\t/**\n+\t*Constructor for the inverted index class\n+\t*/\n+\tconstructor(){\n+\t\tthis.mapIndex = new Map() ;\n+\t\tthis.files = []; //array to hold list of files from the user\n+\t}\n+\t\n+\t/**\n+\t * Method to search for a particular string for now\n+\t */\n+\tsearchIndex(query){\n+\t\tlet results = InvertedIndex.tokenize(query);\n+\t\tlet resultMap = new Map();\n+\t\tfor(var word of results){\n+\t\t\tif(this.mapIndex.has(word) && !resultMap.has(word)){\n+\t\t\t\tresultMap.set(word, this.mapIndex.get(word));\n+\t\t\t}\n+\t\t}\n+\t\treturn resultMap;\n+\t}\n+\n+\t/**\n+\t*Method to upload a book.json file\n+\t*/\n+\tuploadFile(file){\n+\t\t//console.log('uploadFile called');\n+\t\tlet fileReader = new FileReader();\n+\t\tfileReader.onload = (e) => {\n+\t\t\t//console.log(\"onLoad called\");\n+\t\t\tlet parsedJson = JSON.parse(fileReader.result);\n+\t\t\t//console.log(fileReader.result);\n+\t\t\t//console.log(parsedJson);\n+\t\t\tthis.createIndex(parsedJson);\n+\t\t\tfor(var key of this.mapIndex.keys()){\n+\t\t\t\t//console.log(`${key} Occurences(${[...this.mapIndex.get(key)]})`);\n+\t\t\t\t\t//list.innerHTML += `<li><a href=\"#\" onclick=\"shoutOut()\">${key}</a></li>\\n`;\n+\t\t\t}\n+\t\t};\n+\t\tfileReader.readAsText(file);\n+\t}\n+\n+\t/**\n+\t*Method to get an array of all words in a particular text\n+\t*/\n+\tstatic tokenize(text) {\n+\t\treturn text.toLowerCase()\n+\t\t\t.replace(/[^\\w\\s]/g, '')//If it's not a space or a word remove it\n+\t\t\t.split(/\\s+/);//split by spaces of any length\n+\t}\n+\n+\t/**\n+\t*Method to get all text(text and title) in a specific book\n+\t*@book \n+\t*/\n+\tstatic getAllText(book){\n+\t\treturn `${book.title} ${book.text}`;\n+\t}\n+\n+\t/**\n+\t*Method to add word to the mapIndex if it is unique\n+\t*and also add it's docID.\n+\t*/\n+\taddWordToIndex(docId, word){\n+\t\tif(this.mapIndex.has(word)){//check that this word hasn't been keyed\n+\t\t\tthis.mapIndex.get(word).add(docId);//if it has been keyed just add a unique docId\n+\t\t}else{\n+\t\t\tthis.mapIndex.set(word, new Set().add(docId)) ;//Use set for the docId to ensure it is unique\n+\t\t}\n+\t}\n+\n+\t/**\n+\t*Method for building the index from the books json file\n+\t*/\n+\tcreateIndex(booksArray){\n+\t\t//1 start with first document (doc1)\n+\t\tthis.mapIndex.clear(); //Clear existing values when we want to create a new index\n+\t\tfor(let i = 0; i < booksArray.length; i++){\n+\t\t\t//get all the strings in this book\n+\t\t\tlet textArray = InvertedIndex.tokenize(InvertedIndex.getAllText(booksArray[i]));\n+\t\t\tfor(let word of textArray){\n+\t\t\t\tthis.addWordToIndex((i+1), word);\n+\t\t\t}\n+\t\t}\n+\t\treturn this.mapIndex ;\n+\t}\n+}\n+\n+\n+//export default InvertedIndex;\n+\n+\n+var books = [\n+\t{\n+\t\t'title': 'Alice in Wonderland',\n+\t\t'text': 'Alice falls into a rabbit hole and enters a world full of imagination.'\n+\t},\n+\n+\t{\n+\t\t'title': 'The Lord of the Rings: The Fellowship of the Ring.',\n+\t\t'text': 'An unusual alliance of man, elf, dwarf, wizard and hobbit seek to destroy a powerful ring.'\n+\t},\n+\t{\n+\t\t'title': 'Alice in Wonderland',\n+\t\t'text': 'Alice falls into a rabbit hole and enters a world full of imagination.'","path":"src/js/inverted-index.js","position":107,"original_position":107,"commit_id":"1323266d6b7c83d2d3191cee8ee12b61cf0ea046","original_commit_id":"1323266d6b7c83d2d3191cee8ee12b61cf0ea046","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Unexpected tab character                                         no-tabs<br>Expected indentation of 4 space characters but found 0           indent<br>Unnecessarily quoted property 'text' found                       quote-props","created_at":"2016-11-20T15:06:10Z","updated_at":"2016-11-20T15:06:10Z","html_url":"https://github.com/andela-aolaniran/inverted-index/pull/1#discussion_r88803433","pull_request_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/comments/88803433"},"html":{"href":"https://github.com/andela-aolaniran/inverted-index/pull/1#discussion_r88803433"},"pull_request":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1","id":94520769,"html_url":"https://github.com/andela-aolaniran/inverted-index/pull/1","diff_url":"https://github.com/andela-aolaniran/inverted-index/pull/1.diff","patch_url":"https://github.com/andela-aolaniran/inverted-index/pull/1.patch","issue_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/1","number":1,"state":"open","locked":false,"title":"Development","user":{"login":"andela-aolaniran","id":23452705,"avatar_url":"https://avatars.githubusercontent.com/u/23452705?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-aolaniran","html_url":"https://github.com/andela-aolaniran","followers_url":"https://api.github.com/users/andela-aolaniran/followers","following_url":"https://api.github.com/users/andela-aolaniran/following{/other_user}","gists_url":"https://api.github.com/users/andela-aolaniran/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-aolaniran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-aolaniran/subscriptions","organizations_url":"https://api.github.com/users/andela-aolaniran/orgs","repos_url":"https://api.github.com/users/andela-aolaniran/repos","events_url":"https://api.github.com/users/andela-aolaniran/events{/privacy}","received_events_url":"https://api.github.com/users/andela-aolaniran/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-20T15:05:59Z","updated_at":"2016-11-20T15:06:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dfc41dbea0499832260ec79414fc6f27dfc58c61","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/1/comments","statuses_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/statuses/1323266d6b7c83d2d3191cee8ee12b61cf0ea046","head":{"label":"andela-aolaniran:development","ref":"development","sha":"1323266d6b7c83d2d3191cee8ee12b61cf0ea046","user":{"login":"andela-aolaniran","id":23452705,"avatar_url":"https://avatars.githubusercontent.com/u/23452705?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-aolaniran","html_url":"https://github.com/andela-aolaniran","followers_url":"https://api.github.com/users/andela-aolaniran/followers","following_url":"https://api.github.com/users/andela-aolaniran/following{/other_user}","gists_url":"https://api.github.com/users/andela-aolaniran/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-aolaniran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-aolaniran/subscriptions","organizations_url":"https://api.github.com/users/andela-aolaniran/orgs","repos_url":"https://api.github.com/users/andela-aolaniran/repos","events_url":"https://api.github.com/users/andela-aolaniran/events{/privacy}","received_events_url":"https://api.github.com/users/andela-aolaniran/received_events","type":"User","site_admin":false},"repo":{"id":74012324,"name":"inverted-index","full_name":"andela-aolaniran/inverted-index","owner":{"login":"andela-aolaniran","id":23452705,"avatar_url":"https://avatars.githubusercontent.com/u/23452705?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-aolaniran","html_url":"https://github.com/andela-aolaniran","followers_url":"https://api.github.com/users/andela-aolaniran/followers","following_url":"https://api.github.com/users/andela-aolaniran/following{/other_user}","gists_url":"https://api.github.com/users/andela-aolaniran/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-aolaniran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-aolaniran/subscriptions","organizations_url":"https://api.github.com/users/andela-aolaniran/orgs","repos_url":"https://api.github.com/users/andela-aolaniran/repos","events_url":"https://api.github.com/users/andela-aolaniran/events{/privacy}","received_events_url":"https://api.github.com/users/andela-aolaniran/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-aolaniran/inverted-index","description":null,"fork":false,"url":"https://api.github.com/repos/andela-aolaniran/inverted-index","forks_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/forks","keys_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/teams","hooks_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/hooks","issue_events_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/events{/number}","events_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/events","assignees_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/assignees{/user}","branches_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/branches{/branch}","tags_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/tags","blobs_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/languages","stargazers_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/stargazers","contributors_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/contributors","subscribers_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/subscribers","subscription_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/subscription","commits_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/contents/{+path}","compare_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/merges","archive_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/downloads","issues_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues{/number}","pulls_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/labels{/name}","releases_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/releases{/id}","deployments_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/deployments","created_at":"2016-11-17T09:38:35Z","updated_at":"2016-11-17T09:38:35Z","pushed_at":"2016-11-20T15:05:59Z","git_url":"git://github.com/andela-aolaniran/inverted-index.git","ssh_url":"git@github.com:andela-aolaniran/inverted-index.git","clone_url":"https://github.com/andela-aolaniran/inverted-index.git","svn_url":"https://github.com/andela-aolaniran/inverted-index","homepage":null,"size":57,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-aolaniran:master","ref":"master","sha":"2825a197519413ab3851026f4af987ddd4dc0066","user":{"login":"andela-aolaniran","id":23452705,"avatar_url":"https://avatars.githubusercontent.com/u/23452705?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-aolaniran","html_url":"https://github.com/andela-aolaniran","followers_url":"https://api.github.com/users/andela-aolaniran/followers","following_url":"https://api.github.com/users/andela-aolaniran/following{/other_user}","gists_url":"https://api.github.com/users/andela-aolaniran/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-aolaniran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-aolaniran/subscriptions","organizations_url":"https://api.github.com/users/andela-aolaniran/orgs","repos_url":"https://api.github.com/users/andela-aolaniran/repos","events_url":"https://api.github.com/users/andela-aolaniran/events{/privacy}","received_events_url":"https://api.github.com/users/andela-aolaniran/received_events","type":"User","site_admin":false},"repo":{"id":74012324,"name":"inverted-index","full_name":"andela-aolaniran/inverted-index","owner":{"login":"andela-aolaniran","id":23452705,"avatar_url":"https://avatars.githubusercontent.com/u/23452705?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-aolaniran","html_url":"https://github.com/andela-aolaniran","followers_url":"https://api.github.com/users/andela-aolaniran/followers","following_url":"https://api.github.com/users/andela-aolaniran/following{/other_user}","gists_url":"https://api.github.com/users/andela-aolaniran/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-aolaniran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-aolaniran/subscriptions","organizations_url":"https://api.github.com/users/andela-aolaniran/orgs","repos_url":"https://api.github.com/users/andela-aolaniran/repos","events_url":"https://api.github.com/users/andela-aolaniran/events{/privacy}","received_events_url":"https://api.github.com/users/andela-aolaniran/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-aolaniran/inverted-index","description":null,"fork":false,"url":"https://api.github.com/repos/andela-aolaniran/inverted-index","forks_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/forks","keys_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/teams","hooks_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/hooks","issue_events_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/events{/number}","events_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/events","assignees_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/assignees{/user}","branches_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/branches{/branch}","tags_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/tags","blobs_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/languages","stargazers_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/stargazers","contributors_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/contributors","subscribers_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/subscribers","subscription_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/subscription","commits_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/contents/{+path}","compare_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/merges","archive_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/downloads","issues_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues{/number}","pulls_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/labels{/name}","releases_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/releases{/id}","deployments_url":"https://api.github.com/repos/andela-aolaniran/inverted-index/deployments","created_at":"2016-11-17T09:38:35Z","updated_at":"2016-11-17T09:38:35Z","pushed_at":"2016-11-20T15:05:59Z","git_url":"git://github.com/andela-aolaniran/inverted-index.git","ssh_url":"git@github.com:andela-aolaniran/inverted-index.git","clone_url":"https://github.com/andela-aolaniran/inverted-index.git","svn_url":"https://github.com/andela-aolaniran/inverted-index","homepage":null,"size":57,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1"},"html":{"href":"https://github.com/andela-aolaniran/inverted-index/pull/1"},"issue":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/1"},"comments":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andela-aolaniran/inverted-index/statuses/1323266d6b7c83d2d3191cee8ee12b61cf0ea046"}}}}
{"actor":{"display_login":"houndci-bot"}}