{"action":"created","comment":{"url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/comments/66948310","id":66948310,"diff_hunk":"@@ -0,0 +1,93 @@\n+/**\n+ * Elizabeth Mabishi\n+ * Andela Javascript Checkpoint 1: Inverted Index\n+ * Date: 10th June 2016\n+ * version 1.1\n+ */\n+\n+\n+'use strict';\n+\n+// Import the file reader\n+const fs = require('fs');\n+\n+class Index {\n+\n+  // Method to create an Index\n+  createIndex(filePath) {\n+\n+    this.books = JSON.parse(fs.readFileSync(filePath));\n+\n+    this.indexArray = [];\n+\n+\n+    // For each document, turn to string, lowercase, remove special characters\n+    // and trim beginning of line spaces.\n+\n+    // Use forEach to iterate through each document obtaining its position in the document.\n+    this.books.forEach((book, docIndex) => {\n+\n+      var bookObjectString = JSON.stringify(book).toLowerCase().replace(/\\W/g, ' ').replace(/\\s+/g, ' ').trim();\n+\n+      // Concatenate document and split at space to form individual words.\n+      // Map each word to its position in the document\n+      this.indexArray = this.indexArray.concat(bookObjectString.split(' ').map((word, wordIndex) => {\n+\n+        return (word + ' : ' + docIndex + ' : ' + wordIndex);\n+\n+      }));\n+\n+    });\n+  }\n+\n+  // Method to return inverted-index from create index method\n+  getIndex() {\n+\n+    return this.indexArray;\n+  }\n+\n+  // Method to search the index for a term\n+  searchIndex(term) {\n+\n+    try {\n+\n+      if (typeof term === 'string') {\n+        // Filter the index for a search term\n+        var results = this.indexArray.filter(wordStatistics => {\n+\n+          // Ignore case globally through a Regular Expression\n+          const wordToSearch = new RegExp(term, 'gi');\n+\n+          // if a true boolean is returned, wordStatistics is added to results array","path":"jasmine/src/inverted-index.js","position":61,"original_position":61,"commit_id":"3b7b4e7d273978ec47453c4ce38a9067209e6287","original_commit_id":"3b7b4e7d273978ec47453c4ce38a9067209e6287","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":"Line is too long.","created_at":"2016-06-14T10:53:01Z","updated_at":"2016-06-14T10:53:01Z","html_url":"https://github.com/andela-emabishi/inverted-index/pull/1#discussion_r66948310","pull_request_url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/comments/66948310"},"html":{"href":"https://github.com/andela-emabishi/inverted-index/pull/1#discussion_r66948310"},"pull_request":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1","id":72532108,"html_url":"https://github.com/andela-emabishi/inverted-index/pull/1","diff_url":"https://github.com/andela-emabishi/inverted-index/pull/1.diff","patch_url":"https://github.com/andela-emabishi/inverted-index/pull/1.patch","issue_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/1","number":1,"state":"open","locked":false,"title":"Dev","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"body":"Hound style check","created_at":"2016-06-03T16:12:01Z","updated_at":"2016-06-14T10:53:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1782c8fee54587f68fc870dc41d6115510e2fcc4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/1/comments","statuses_url":"https://api.github.com/repos/andela-emabishi/inverted-index/statuses/3b7b4e7d273978ec47453c4ce38a9067209e6287","head":{"label":"andela-emabishi:dev","ref":"dev","sha":"3b7b4e7d273978ec47453c4ce38a9067209e6287","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"repo":{"id":60010637,"name":"inverted-index","full_name":"andela-emabishi/inverted-index","owner":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-emabishi/inverted-index","description":"Javascript Checkpoint 1: Develop an inverted index object that takes a JSON array of text objects and creates an index from the array. The index allows a user to search for text blocks in the array that contain a specified collection of words.","fork":false,"url":"https://api.github.com/repos/andela-emabishi/inverted-index","forks_url":"https://api.github.com/repos/andela-emabishi/inverted-index/forks","keys_url":"https://api.github.com/repos/andela-emabishi/inverted-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-emabishi/inverted-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-emabishi/inverted-index/teams","hooks_url":"https://api.github.com/repos/andela-emabishi/inverted-index/hooks","issue_events_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/events{/number}","events_url":"https://api.github.com/repos/andela-emabishi/inverted-index/events","assignees_url":"https://api.github.com/repos/andela-emabishi/inverted-index/assignees{/user}","branches_url":"https://api.github.com/repos/andela-emabishi/inverted-index/branches{/branch}","tags_url":"https://api.github.com/repos/andela-emabishi/inverted-index/tags","blobs_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-emabishi/inverted-index/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-emabishi/inverted-index/languages","stargazers_url":"https://api.github.com/repos/andela-emabishi/inverted-index/stargazers","contributors_url":"https://api.github.com/repos/andela-emabishi/inverted-index/contributors","subscribers_url":"https://api.github.com/repos/andela-emabishi/inverted-index/subscribers","subscription_url":"https://api.github.com/repos/andela-emabishi/inverted-index/subscription","commits_url":"https://api.github.com/repos/andela-emabishi/inverted-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-emabishi/inverted-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-emabishi/inverted-index/contents/{+path}","compare_url":"https://api.github.com/repos/andela-emabishi/inverted-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-emabishi/inverted-index/merges","archive_url":"https://api.github.com/repos/andela-emabishi/inverted-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-emabishi/inverted-index/downloads","issues_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues{/number}","pulls_url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-emabishi/inverted-index/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-emabishi/inverted-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-emabishi/inverted-index/labels{/name}","releases_url":"https://api.github.com/repos/andela-emabishi/inverted-index/releases{/id}","deployments_url":"https://api.github.com/repos/andela-emabishi/inverted-index/deployments","created_at":"2016-05-30T13:05:16Z","updated_at":"2016-05-30T13:24:34Z","pushed_at":"2016-06-14T10:52:54Z","git_url":"git://github.com/andela-emabishi/inverted-index.git","ssh_url":"git@github.com:andela-emabishi/inverted-index.git","clone_url":"https://github.com/andela-emabishi/inverted-index.git","svn_url":"https://github.com/andela-emabishi/inverted-index","homepage":null,"size":72,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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-emabishi:master","ref":"master","sha":"a2454b98aa3c678532bc94cf6ba24ae4282d7abf","user":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"repo":{"id":60010637,"name":"inverted-index","full_name":"andela-emabishi/inverted-index","owner":{"login":"andela-emabishi","id":19430113,"avatar_url":"https://avatars.githubusercontent.com/u/19430113?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-emabishi","html_url":"https://github.com/andela-emabishi","followers_url":"https://api.github.com/users/andela-emabishi/followers","following_url":"https://api.github.com/users/andela-emabishi/following{/other_user}","gists_url":"https://api.github.com/users/andela-emabishi/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-emabishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-emabishi/subscriptions","organizations_url":"https://api.github.com/users/andela-emabishi/orgs","repos_url":"https://api.github.com/users/andela-emabishi/repos","events_url":"https://api.github.com/users/andela-emabishi/events{/privacy}","received_events_url":"https://api.github.com/users/andela-emabishi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-emabishi/inverted-index","description":"Javascript Checkpoint 1: Develop an inverted index object that takes a JSON array of text objects and creates an index from the array. The index allows a user to search for text blocks in the array that contain a specified collection of words.","fork":false,"url":"https://api.github.com/repos/andela-emabishi/inverted-index","forks_url":"https://api.github.com/repos/andela-emabishi/inverted-index/forks","keys_url":"https://api.github.com/repos/andela-emabishi/inverted-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-emabishi/inverted-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-emabishi/inverted-index/teams","hooks_url":"https://api.github.com/repos/andela-emabishi/inverted-index/hooks","issue_events_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/events{/number}","events_url":"https://api.github.com/repos/andela-emabishi/inverted-index/events","assignees_url":"https://api.github.com/repos/andela-emabishi/inverted-index/assignees{/user}","branches_url":"https://api.github.com/repos/andela-emabishi/inverted-index/branches{/branch}","tags_url":"https://api.github.com/repos/andela-emabishi/inverted-index/tags","blobs_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-emabishi/inverted-index/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-emabishi/inverted-index/languages","stargazers_url":"https://api.github.com/repos/andela-emabishi/inverted-index/stargazers","contributors_url":"https://api.github.com/repos/andela-emabishi/inverted-index/contributors","subscribers_url":"https://api.github.com/repos/andela-emabishi/inverted-index/subscribers","subscription_url":"https://api.github.com/repos/andela-emabishi/inverted-index/subscription","commits_url":"https://api.github.com/repos/andela-emabishi/inverted-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-emabishi/inverted-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-emabishi/inverted-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-emabishi/inverted-index/contents/{+path}","compare_url":"https://api.github.com/repos/andela-emabishi/inverted-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-emabishi/inverted-index/merges","archive_url":"https://api.github.com/repos/andela-emabishi/inverted-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-emabishi/inverted-index/downloads","issues_url":"https://api.github.com/repos/andela-emabishi/inverted-index/issues{/number}","pulls_url":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-emabishi/inverted-index/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-emabishi/inverted-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-emabishi/inverted-index/labels{/name}","releases_url":"https://api.github.com/repos/andela-emabishi/inverted-index/releases{/id}","deployments_url":"https://api.github.com/repos/andela-emabishi/inverted-index/deployments","created_at":"2016-05-30T13:05:16Z","updated_at":"2016-05-30T13:24:34Z","pushed_at":"2016-06-14T10:52:54Z","git_url":"git://github.com/andela-emabishi/inverted-index.git","ssh_url":"git@github.com:andela-emabishi/inverted-index.git","clone_url":"https://github.com/andela-emabishi/inverted-index.git","svn_url":"https://github.com/andela-emabishi/inverted-index","homepage":null,"size":72,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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-emabishi/inverted-index/pulls/1"},"html":{"href":"https://github.com/andela-emabishi/inverted-index/pull/1"},"issue":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/1"},"comments":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andela-emabishi/inverted-index/statuses/3b7b4e7d273978ec47453c4ce38a9067209e6287"}}}}
{"actor":{"display_login":"houndci-bot"}}