{"action":"created","comment":{"url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/comments/91445494","pull_request_review_id":11953201,"id":91445494,"diff_hunk":"@@ -0,0 +1,136 @@\n+/*  eslint-disable no-unused-vars*/\n+/**\n+ * InvertedIndex class with constructor\n+ * @class\n+ */\n+class InvertedIndex {\n+  /**\n+   * class constructor\n+   * @constructor\n+   */\n+  constructor() {\n+    this.fileMap = {};\n+    this.indexMap = {};\n+    this.docNumber = {};\n+    this.uploadedFiles = {};\n+  }\n+  /**\n+   * Create index\n+   * @function\n+   * @param {Array} fileContent json array\n+   * @param {string} fileName Name of the file being indexed\n+   * @return {void}\n+   */\n+  createIndex(fileContent, fileName) {\n+    this.docCount = [];\n+    this.count = 0;\n+    fileContent.forEach((content, index) => {\n+      this.docCount.push(parseInt(index, 10));\n+      this.count += 1;\n+      const combineWords = `${content.title} ${content.text}`;\n+      const tokenizedWords = InvertedIndex.token(combineWords);\n+      const wordIndex = new Set(tokenizedWords);\n+      this.mapWords(wordIndex, this.count);\n+    });\n+    this.fileMap[fileName] = this.indexMap;\n+    this.docNumber[fileName] = this.docCount;\n+  }\n+  /**\n+   * Get tokens in a string of text.\n+   * @function\n+   * @param {String} fileContent word to be tokenize.\n+   * @return {Array} array of tokens\n+   */\n+  static token(fileContent) {\n+    return fileContent.toLowerCase()\n+    .match(/\\w+/g);\n+  }\n+  /**\n+   * validates the file type using regEXP\n+   * @param  {file}    file that is being uploaded\n+   * @return {string}      error message\n+   */\n+  static fileIsValid(file) {\n+    if (!file.name.toLowerCase().match(/\\.json$/)) {\n+      return false;\n+    }\n+    return true;\n+  }\n+  /**\n+   * check if the file content is a valid object\n+   * @param  {object} content file content which can be a valid json object\n+   * @return {string}         error message\n+   */\n+  static contentIsValid(content) {\n+    if (typeof (content) !== 'object') {\n+      return false;\n+    }\n+    return true;\n+  }\n+  /**\n+   * Checks if the file content is in a standard array format\n+   * @return {string}         error message\n+   */\n+  static contentIsEmpty() {\n+    if (InvertedIndex.docCount === undefined) {\n+      return 'JSON file should be an array of objects';\n+    }\n+  }\n+  /**\n+   * Map Array of words to indexMap.\n+   * @function\n+   * @param {String} words unique word to be mapped.\n+   * @param {Integer} tag the document number the word exists.\n+   * @return {void}\n+   */\n+  mapWords(words, tag) {\n+    words.forEach((word) => {\n+      if (word in this.indexMap) {\n+        this.indexMap[word].push(tag);\n+      } else {\n+        this.indexMap[word] = [tag];\n+      }\n+    });\n+  }\n+  /**\n+   * gets the index map\n+   * @param {string} title title of the file to be searched\n+   * @return {object} all the words that exists in the documents with their tag\n+   */\n+  getIndex(title) {\n+    return this.fileMap[title];\n+  }\n+  /**\n+   * searches through the index map\n+   * @param  {string} query the set of string being input in search box\n+   * @param {string} title    the file title to be searched\n+   * @return {object} result     the search result is returned\n+   */\n+  search(query, title) {\n+    if (title === 'all') {\n+      const result = {};\n+      const searchQuery = query.split(' ');\n+      Object.keys(this.fileMap).forEach((book) => {\n+        const searchResult = {};\n+        const dictionary = this.fileMap[book];\n+        searchQuery.forEach((word) => {","path":"src/inverted-index.js","position":116,"original_position":116,"commit_id":"144d4c34280ef540ee789aa66e788697de64cf01","original_commit_id":"144d4c34280ef540ee789aa66e788697de64cf01","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":"'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').","created_at":"2016-12-08T05:09:16Z","updated_at":"2016-12-08T05:09:16Z","html_url":"https://github.com/andela-tisrael/checkpoint-inverted-index/pull/2#discussion_r91445494","pull_request_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/comments/91445494"},"html":{"href":"https://github.com/andela-tisrael/checkpoint-inverted-index/pull/2#discussion_r91445494"},"pull_request":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2","id":97060034,"html_url":"https://github.com/andela-tisrael/checkpoint-inverted-index/pull/2","diff_url":"https://github.com/andela-tisrael/checkpoint-inverted-index/pull/2.diff","patch_url":"https://github.com/andela-tisrael/checkpoint-inverted-index/pull/2.patch","issue_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/2","number":2,"state":"open","locked":false,"title":"Developments","user":{"login":"andela-tisrael","id":19914657,"avatar_url":"https://avatars.githubusercontent.com/u/19914657?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-tisrael","html_url":"https://github.com/andela-tisrael","followers_url":"https://api.github.com/users/andela-tisrael/followers","following_url":"https://api.github.com/users/andela-tisrael/following{/other_user}","gists_url":"https://api.github.com/users/andela-tisrael/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-tisrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-tisrael/subscriptions","organizations_url":"https://api.github.com/users/andela-tisrael/orgs","repos_url":"https://api.github.com/users/andela-tisrael/repos","events_url":"https://api.github.com/users/andela-tisrael/events{/privacy}","received_events_url":"https://api.github.com/users/andela-tisrael/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\n\r\nThis pull request was created to check houndCI\r\n\r\n### Description of Task to be completed?\r\n\r\nrefactor of code and ensure no houndCI flag is raised\r\n\r\n### How should this be manually tested?\r\n`npm test`\r\n\r\n### Any background context you want to provide?\r\n\r\nNo background context\r\n\r\n### Screenshots (if appropriate)\r\n\r\nNot Applicable\r\n\r\n### Questions:\r\n\r\nNot Applicable.","created_at":"2016-12-08T05:09:06Z","updated_at":"2016-12-08T05:09:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f737ffe6717159b1eaeb3bc00637a276011afd28","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2/commits","review_comments_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2/comments","review_comment_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/2/comments","statuses_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/statuses/144d4c34280ef540ee789aa66e788697de64cf01","head":{"label":"andela-tisrael:developments","ref":"developments","sha":"144d4c34280ef540ee789aa66e788697de64cf01","user":{"login":"andela-tisrael","id":19914657,"avatar_url":"https://avatars.githubusercontent.com/u/19914657?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-tisrael","html_url":"https://github.com/andela-tisrael","followers_url":"https://api.github.com/users/andela-tisrael/followers","following_url":"https://api.github.com/users/andela-tisrael/following{/other_user}","gists_url":"https://api.github.com/users/andela-tisrael/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-tisrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-tisrael/subscriptions","organizations_url":"https://api.github.com/users/andela-tisrael/orgs","repos_url":"https://api.github.com/users/andela-tisrael/repos","events_url":"https://api.github.com/users/andela-tisrael/events{/privacy}","received_events_url":"https://api.github.com/users/andela-tisrael/received_events","type":"User","site_admin":false},"repo":{"id":74340100,"name":"checkpoint-inverted-index","full_name":"andela-tisrael/checkpoint-inverted-index","owner":{"login":"andela-tisrael","id":19914657,"avatar_url":"https://avatars.githubusercontent.com/u/19914657?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-tisrael","html_url":"https://github.com/andela-tisrael","followers_url":"https://api.github.com/users/andela-tisrael/followers","following_url":"https://api.github.com/users/andela-tisrael/following{/other_user}","gists_url":"https://api.github.com/users/andela-tisrael/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-tisrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-tisrael/subscriptions","organizations_url":"https://api.github.com/users/andela-tisrael/orgs","repos_url":"https://api.github.com/users/andela-tisrael/repos","events_url":"https://api.github.com/users/andela-tisrael/events{/privacy}","received_events_url":"https://api.github.com/users/andela-tisrael/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-tisrael/checkpoint-inverted-index","description":"Inverted Index","fork":false,"url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index","forks_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/forks","keys_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/teams","hooks_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/hooks","issue_events_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/events{/number}","events_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/events","assignees_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/assignees{/user}","branches_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/branches{/branch}","tags_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/tags","blobs_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/languages","stargazers_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/stargazers","contributors_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/contributors","subscribers_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/subscribers","subscription_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/subscription","commits_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/contents/{+path}","compare_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/merges","archive_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/downloads","issues_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues{/number}","pulls_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/labels{/name}","releases_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/releases{/id}","deployments_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/deployments","created_at":"2016-11-21T08:02:14Z","updated_at":"2016-11-25T09:23:53Z","pushed_at":"2016-12-08T05:09:06Z","git_url":"git://github.com/andela-tisrael/checkpoint-inverted-index.git","ssh_url":"git@github.com:andela-tisrael/checkpoint-inverted-index.git","clone_url":"https://github.com/andela-tisrael/checkpoint-inverted-index.git","svn_url":"https://github.com/andela-tisrael/checkpoint-inverted-index","homepage":"https://andela-invertedindex.herokuapp.com/","size":824,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-tisrael:master","ref":"master","sha":"dc93ccb364b31b9fc4f2b6b02ff886f42b140a2a","user":{"login":"andela-tisrael","id":19914657,"avatar_url":"https://avatars.githubusercontent.com/u/19914657?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-tisrael","html_url":"https://github.com/andela-tisrael","followers_url":"https://api.github.com/users/andela-tisrael/followers","following_url":"https://api.github.com/users/andela-tisrael/following{/other_user}","gists_url":"https://api.github.com/users/andela-tisrael/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-tisrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-tisrael/subscriptions","organizations_url":"https://api.github.com/users/andela-tisrael/orgs","repos_url":"https://api.github.com/users/andela-tisrael/repos","events_url":"https://api.github.com/users/andela-tisrael/events{/privacy}","received_events_url":"https://api.github.com/users/andela-tisrael/received_events","type":"User","site_admin":false},"repo":{"id":74340100,"name":"checkpoint-inverted-index","full_name":"andela-tisrael/checkpoint-inverted-index","owner":{"login":"andela-tisrael","id":19914657,"avatar_url":"https://avatars.githubusercontent.com/u/19914657?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-tisrael","html_url":"https://github.com/andela-tisrael","followers_url":"https://api.github.com/users/andela-tisrael/followers","following_url":"https://api.github.com/users/andela-tisrael/following{/other_user}","gists_url":"https://api.github.com/users/andela-tisrael/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-tisrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-tisrael/subscriptions","organizations_url":"https://api.github.com/users/andela-tisrael/orgs","repos_url":"https://api.github.com/users/andela-tisrael/repos","events_url":"https://api.github.com/users/andela-tisrael/events{/privacy}","received_events_url":"https://api.github.com/users/andela-tisrael/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-tisrael/checkpoint-inverted-index","description":"Inverted Index","fork":false,"url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index","forks_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/forks","keys_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/teams","hooks_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/hooks","issue_events_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/events{/number}","events_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/events","assignees_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/assignees{/user}","branches_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/branches{/branch}","tags_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/tags","blobs_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/languages","stargazers_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/stargazers","contributors_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/contributors","subscribers_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/subscribers","subscription_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/subscription","commits_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/contents/{+path}","compare_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/merges","archive_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/downloads","issues_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues{/number}","pulls_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/labels{/name}","releases_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/releases{/id}","deployments_url":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/deployments","created_at":"2016-11-21T08:02:14Z","updated_at":"2016-11-25T09:23:53Z","pushed_at":"2016-12-08T05:09:06Z","git_url":"git://github.com/andela-tisrael/checkpoint-inverted-index.git","ssh_url":"git@github.com:andela-tisrael/checkpoint-inverted-index.git","clone_url":"https://github.com/andela-tisrael/checkpoint-inverted-index.git","svn_url":"https://github.com/andela-tisrael/checkpoint-inverted-index","homepage":"https://andela-invertedindex.herokuapp.com/","size":824,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2"},"html":{"href":"https://github.com/andela-tisrael/checkpoint-inverted-index/pull/2"},"issue":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/2"},"comments":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/andela-tisrael/checkpoint-inverted-index/statuses/144d4c34280ef540ee789aa66e788697de64cf01"}}}}
{"actor":{"display_login":"houndci-bot"}}