{"action":"created","comment":{"url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/comments/83901872","pull_request_review_id":4714532,"id":83901872,"diff_hunk":"@@ -0,0 +1,233 @@\n+library(liqueueR)\n+setwd(\"~/Documents/CMU/36-750StatComp/problem-bank\")\n+\n+# autocomplete\n+# 1.  take in data, sort by name FUN:SplitSort\n+# 2.  find the first and last element that matches\n+#     a string using binary search FUN:BinarySearchBounds\n+# 3.  take the elements that match a string and sort by weight\n+# 4.  return top k\n+\n+###########\n+# 1.\n+###########\n+#' Split tab delimited file and sort alphabetically by word\n+#'\n+#' Take a vector of unique IDs from original data set and convert to binary matches for the comparisons of each entity in original dataset\n+#'\n+#' @param data.file tab delimited data file with the first column containing weights and second column containing the words\n+#' @return A data.frame with two columns, 'weight' and 'word', with the rows sorted alphabetically by 'word'\n+#' @examples\n+#' \n+SplitSort <- function(data.file){\n+  data.split <- read.table(data.file, sep=\"\\t\", header=FALSE, strip.white=TRUE,\n+                           comment='', quote=\"\", skip=1, col.names = c(\"weight\", \"word\"))\n+  split.sort <- data.split[order(data.split$word), ]\n+  return(split.sort)\n+}\n+\n+# movies <- SplitSort(\"Data/movies.txt\")\n+# baby.names <- SplitSort(\"Data/baby-names.txt\")\n+wiki <- SplitSort(\"Data/wiktionary.txt\")\n+\n+#########\n+# 2.\n+#########\n+\n+BinarySearchBounds <- function(query, word.seq, first=NULL, last=NULL, verbose=NULL){\n+  \n+  if(is.null(verbose)) {\n+    verbose <- FALSE\n+  } else {\n+    verbose <- verbose\n+  }\n+  \n+  if(is.null(last)){\n+    last <- length(word.seq) - 1\n+  } else{\n+    last <- last\n+  }\n+  if(is.null(first)){\n+    first <- 0\n+  } else{\n+    first <- first\n+  }\n+  \n+  word.seq <- as.character(word.seq)\n+  \n+  mid <- ceiling((first + last)/2)\n+  \n+  while(word.seq[mid] != query){ # and first <= last?\n+    mid <- ceiling((first + last)/2)\n+    if(verbose) print(mid)\n+    if (first > last) {\n+      break\n+    } else if (word.seq[mid] < query){\n+      first <- mid + 1\n+    } else if(word.seq[mid] > query) {\n+      last <- mid - 1\n+    }\n+    if(verbose) print(c(first, last))\n+  }\n+  lower <- mid\n+  upper <- mid\n+  \n+  if(word.seq[mid] != query){\n+    return(c(lower, upper, FALSE))\n+  } else{\n+    while(upper < length(word.seq)){\n+      if(query != word.seq[upper + 1]) break\n+      if(query == word.seq[upper + 1]){\n+        upper <- upper + 1\n+      }\n+    }\n+    while(lower > 1){\n+      if(query != word.seq[lower - 1]) break\n+      if(query == word.seq[lower - 1]){\n+        lower <- lower - 1\n+      }\n+    }\n+    return(c(lower, upper, TRUE))\n+  }\n+}\n+\n+BinarySearchBounds(\"dog\", c( \"cat\", \"cat\", \"dog\",  \"pig\"))","path":"in-class-ass.R","position":94,"original_position":94,"commit_id":"9b2c0a68d1a24e848d922389af44c104e7a68930","original_commit_id":"9b2c0a68d1a24e848d922389af44c104e7a68930","user":{"login":"sessabhoy","id":21344410,"avatar_url":"https://avatars.githubusercontent.com/u/21344410?v=3","gravatar_id":"","url":"https://api.github.com/users/sessabhoy","html_url":"https://github.com/sessabhoy","followers_url":"https://api.github.com/users/sessabhoy/followers","following_url":"https://api.github.com/users/sessabhoy/following{/other_user}","gists_url":"https://api.github.com/users/sessabhoy/gists{/gist_id}","starred_url":"https://api.github.com/users/sessabhoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sessabhoy/subscriptions","organizations_url":"https://api.github.com/users/sessabhoy/orgs","repos_url":"https://api.github.com/users/sessabhoy/repos","events_url":"https://api.github.com/users/sessabhoy/events{/privacy}","received_events_url":"https://api.github.com/users/sessabhoy/received_events","type":"User","site_admin":false},"body":"For the final draft, put all test functions into another file and use test_that function.","created_at":"2016-10-18T17:02:17Z","updated_at":"2016-10-18T17:02:17Z","html_url":"https://github.com/kaylafrisoli/autocomplete/pull/2#discussion_r83901872","pull_request_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/comments/83901872"},"html":{"href":"https://github.com/kaylafrisoli/autocomplete/pull/2#discussion_r83901872"},"pull_request":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2","id":89849572,"html_url":"https://github.com/kaylafrisoli/autocomplete/pull/2","diff_url":"https://github.com/kaylafrisoli/autocomplete/pull/2.diff","patch_url":"https://github.com/kaylafrisoli/autocomplete/pull/2.patch","issue_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/2","number":2,"state":"open","locked":false,"title":"peer review","user":{"login":"kaylafrisoli","id":16839990,"avatar_url":"https://avatars.githubusercontent.com/u/16839990?v=3","gravatar_id":"","url":"https://api.github.com/users/kaylafrisoli","html_url":"https://github.com/kaylafrisoli","followers_url":"https://api.github.com/users/kaylafrisoli/followers","following_url":"https://api.github.com/users/kaylafrisoli/following{/other_user}","gists_url":"https://api.github.com/users/kaylafrisoli/gists{/gist_id}","starred_url":"https://api.github.com/users/kaylafrisoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaylafrisoli/subscriptions","organizations_url":"https://api.github.com/users/kaylafrisoli/orgs","repos_url":"https://api.github.com/users/kaylafrisoli/repos","events_url":"https://api.github.com/users/kaylafrisoli/events{/privacy}","received_events_url":"https://api.github.com/users/kaylafrisoli/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-18T16:14:49Z","updated_at":"2016-10-18T17:02:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a442bdaf0713a6df3498d1841abefe0ab0a9c1b","assignee":{"login":"sessabhoy","id":21344410,"avatar_url":"https://avatars.githubusercontent.com/u/21344410?v=3","gravatar_id":"","url":"https://api.github.com/users/sessabhoy","html_url":"https://github.com/sessabhoy","followers_url":"https://api.github.com/users/sessabhoy/followers","following_url":"https://api.github.com/users/sessabhoy/following{/other_user}","gists_url":"https://api.github.com/users/sessabhoy/gists{/gist_id}","starred_url":"https://api.github.com/users/sessabhoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sessabhoy/subscriptions","organizations_url":"https://api.github.com/users/sessabhoy/orgs","repos_url":"https://api.github.com/users/sessabhoy/repos","events_url":"https://api.github.com/users/sessabhoy/events{/privacy}","received_events_url":"https://api.github.com/users/sessabhoy/received_events","type":"User","site_admin":false},"assignees":[{"login":"sessabhoy","id":21344410,"avatar_url":"https://avatars.githubusercontent.com/u/21344410?v=3","gravatar_id":"","url":"https://api.github.com/users/sessabhoy","html_url":"https://github.com/sessabhoy","followers_url":"https://api.github.com/users/sessabhoy/followers","following_url":"https://api.github.com/users/sessabhoy/following{/other_user}","gists_url":"https://api.github.com/users/sessabhoy/gists{/gist_id}","starred_url":"https://api.github.com/users/sessabhoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sessabhoy/subscriptions","organizations_url":"https://api.github.com/users/sessabhoy/orgs","repos_url":"https://api.github.com/users/sessabhoy/repos","events_url":"https://api.github.com/users/sessabhoy/events{/privacy}","received_events_url":"https://api.github.com/users/sessabhoy/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2/commits","review_comments_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2/comments","review_comment_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/2/comments","statuses_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/statuses/9b2c0a68d1a24e848d922389af44c104e7a68930","head":{"label":"kaylafrisoli:class-ex","ref":"class-ex","sha":"9b2c0a68d1a24e848d922389af44c104e7a68930","user":{"login":"kaylafrisoli","id":16839990,"avatar_url":"https://avatars.githubusercontent.com/u/16839990?v=3","gravatar_id":"","url":"https://api.github.com/users/kaylafrisoli","html_url":"https://github.com/kaylafrisoli","followers_url":"https://api.github.com/users/kaylafrisoli/followers","following_url":"https://api.github.com/users/kaylafrisoli/following{/other_user}","gists_url":"https://api.github.com/users/kaylafrisoli/gists{/gist_id}","starred_url":"https://api.github.com/users/kaylafrisoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaylafrisoli/subscriptions","organizations_url":"https://api.github.com/users/kaylafrisoli/orgs","repos_url":"https://api.github.com/users/kaylafrisoli/repos","events_url":"https://api.github.com/users/kaylafrisoli/events{/privacy}","received_events_url":"https://api.github.com/users/kaylafrisoli/received_events","type":"User","site_admin":false},"repo":{"id":70634972,"name":"autocomplete","full_name":"kaylafrisoli/autocomplete","owner":{"login":"kaylafrisoli","id":16839990,"avatar_url":"https://avatars.githubusercontent.com/u/16839990?v=3","gravatar_id":"","url":"https://api.github.com/users/kaylafrisoli","html_url":"https://github.com/kaylafrisoli","followers_url":"https://api.github.com/users/kaylafrisoli/followers","following_url":"https://api.github.com/users/kaylafrisoli/following{/other_user}","gists_url":"https://api.github.com/users/kaylafrisoli/gists{/gist_id}","starred_url":"https://api.github.com/users/kaylafrisoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaylafrisoli/subscriptions","organizations_url":"https://api.github.com/users/kaylafrisoli/orgs","repos_url":"https://api.github.com/users/kaylafrisoli/repos","events_url":"https://api.github.com/users/kaylafrisoli/events{/privacy}","received_events_url":"https://api.github.com/users/kaylafrisoli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kaylafrisoli/autocomplete","description":null,"fork":false,"url":"https://api.github.com/repos/kaylafrisoli/autocomplete","forks_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/forks","keys_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/teams","hooks_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/hooks","issue_events_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/events{/number}","events_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/events","assignees_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/assignees{/user}","branches_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/branches{/branch}","tags_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/tags","blobs_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/statuses/{sha}","languages_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/languages","stargazers_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/stargazers","contributors_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/contributors","subscribers_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/subscribers","subscription_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/subscription","commits_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/contents/{+path}","compare_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/merges","archive_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/downloads","issues_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues{/number}","pulls_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls{/number}","milestones_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/milestones{/number}","notifications_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/labels{/name}","releases_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/releases{/id}","deployments_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/deployments","created_at":"2016-10-11T20:59:53Z","updated_at":"2016-10-12T18:02:53Z","pushed_at":"2016-10-18T16:14:49Z","git_url":"git://github.com/kaylafrisoli/autocomplete.git","ssh_url":"git@github.com:kaylafrisoli/autocomplete.git","clone_url":"https://github.com/kaylafrisoli/autocomplete.git","svn_url":"https://github.com/kaylafrisoli/autocomplete","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":"R","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":"kaylafrisoli:master","ref":"master","sha":"9703fc29e1aff051ef026af0ce3e2c317ea58a15","user":{"login":"kaylafrisoli","id":16839990,"avatar_url":"https://avatars.githubusercontent.com/u/16839990?v=3","gravatar_id":"","url":"https://api.github.com/users/kaylafrisoli","html_url":"https://github.com/kaylafrisoli","followers_url":"https://api.github.com/users/kaylafrisoli/followers","following_url":"https://api.github.com/users/kaylafrisoli/following{/other_user}","gists_url":"https://api.github.com/users/kaylafrisoli/gists{/gist_id}","starred_url":"https://api.github.com/users/kaylafrisoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaylafrisoli/subscriptions","organizations_url":"https://api.github.com/users/kaylafrisoli/orgs","repos_url":"https://api.github.com/users/kaylafrisoli/repos","events_url":"https://api.github.com/users/kaylafrisoli/events{/privacy}","received_events_url":"https://api.github.com/users/kaylafrisoli/received_events","type":"User","site_admin":false},"repo":{"id":70634972,"name":"autocomplete","full_name":"kaylafrisoli/autocomplete","owner":{"login":"kaylafrisoli","id":16839990,"avatar_url":"https://avatars.githubusercontent.com/u/16839990?v=3","gravatar_id":"","url":"https://api.github.com/users/kaylafrisoli","html_url":"https://github.com/kaylafrisoli","followers_url":"https://api.github.com/users/kaylafrisoli/followers","following_url":"https://api.github.com/users/kaylafrisoli/following{/other_user}","gists_url":"https://api.github.com/users/kaylafrisoli/gists{/gist_id}","starred_url":"https://api.github.com/users/kaylafrisoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaylafrisoli/subscriptions","organizations_url":"https://api.github.com/users/kaylafrisoli/orgs","repos_url":"https://api.github.com/users/kaylafrisoli/repos","events_url":"https://api.github.com/users/kaylafrisoli/events{/privacy}","received_events_url":"https://api.github.com/users/kaylafrisoli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kaylafrisoli/autocomplete","description":null,"fork":false,"url":"https://api.github.com/repos/kaylafrisoli/autocomplete","forks_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/forks","keys_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/teams","hooks_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/hooks","issue_events_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/events{/number}","events_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/events","assignees_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/assignees{/user}","branches_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/branches{/branch}","tags_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/tags","blobs_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/statuses/{sha}","languages_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/languages","stargazers_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/stargazers","contributors_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/contributors","subscribers_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/subscribers","subscription_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/subscription","commits_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/contents/{+path}","compare_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/merges","archive_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/downloads","issues_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues{/number}","pulls_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls{/number}","milestones_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/milestones{/number}","notifications_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/labels{/name}","releases_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/releases{/id}","deployments_url":"https://api.github.com/repos/kaylafrisoli/autocomplete/deployments","created_at":"2016-10-11T20:59:53Z","updated_at":"2016-10-12T18:02:53Z","pushed_at":"2016-10-18T16:14:49Z","git_url":"git://github.com/kaylafrisoli/autocomplete.git","ssh_url":"git@github.com:kaylafrisoli/autocomplete.git","clone_url":"https://github.com/kaylafrisoli/autocomplete.git","svn_url":"https://github.com/kaylafrisoli/autocomplete","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":"R","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/kaylafrisoli/autocomplete/pulls/2"},"html":{"href":"https://github.com/kaylafrisoli/autocomplete/pull/2"},"issue":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/2"},"comments":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/kaylafrisoli/autocomplete/statuses/9b2c0a68d1a24e848d922389af44c104e7a68930"}}}}
{"actor":{"display_login":"sessabhoy"}}