{"action":"opened","number":534,"pull_request":{"url":"https://api.github.com/repos/harvard-lil/capstone/pulls/534","id":219486353,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5NDg2MzUz","html_url":"https://github.com/harvard-lil/capstone/pull/534","diff_url":"https://github.com/harvard-lil/capstone/pull/534.diff","patch_url":"https://github.com/harvard-lil/capstone/pull/534.patch","issue_url":"https://api.github.com/repos/harvard-lil/capstone/issues/534","number":534,"state":"open","locked":false,"title":"Add ngrams endpoint","user":{"login":"jcushman","id":376272,"node_id":"MDQ6VXNlcjM3NjI3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/376272?v=4","gravatar_id":"","url":"https://api.github.com/users/jcushman","html_url":"https://github.com/jcushman","followers_url":"https://api.github.com/users/jcushman/followers","following_url":"https://api.github.com/users/jcushman/following{/other_user}","gists_url":"https://api.github.com/users/jcushman/gists{/gist_id}","starred_url":"https://api.github.com/users/jcushman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcushman/subscriptions","organizations_url":"https://api.github.com/users/jcushman/orgs","repos_url":"https://api.github.com/users/jcushman/repos","events_url":"https://api.github.com/users/jcushman/events{/privacy}","received_events_url":"https://api.github.com/users/jcushman/received_events","type":"User","site_admin":false},"body":"This is a first pass at adding an ngrams endpoint, which will allow you to query the number of occurrences per year of a phrase up to three words long, optionally filtering by jurisdiction. \r\n\r\n![image](https://user-images.githubusercontent.com/376272/46310394-341a4e80-c58d-11e8-89fe-0baaf613135b.png)\r\n\r\n(I didn't expose it other than through the API -- that would be a next phase.)\r\n\r\nI'm currently going with an approach that is relatively light on data storage, given what's possible in postgres. Each known token has an ID stored in one table, and the count for each combination of id-id-id-jurisdiction-year is stored in another table. A general query for \"in this court\" then gets translated to three IDs, and we sum up the entries for id-id-id-* to get a count for each year. A query for \"court\" gets translated to a single ID, and we sum up the entries for id-*-*-* to get a count for each year.\r\n\r\nI don't know whether this will work at scale, so I have it behind a feature flag (`NGRAMS_FEATURE`). The idea is to run `fab ngram_jurisdictions` on prod to do the indexing, then try turning on `NGRAMS_FEATURE` on beta and see if it's fast enough to enable on prod. Ngrams could get a lot more cpu and disk efficient than this with a fancy tree structure, but I'm hoping this gets us close enough.","created_at":"2018-10-01T19:20:32Z","updated_at":"2018-10-01T19:20:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/harvard-lil/capstone/pulls/534/commits","review_comments_url":"https://api.github.com/repos/harvard-lil/capstone/pulls/534/comments","review_comment_url":"https://api.github.com/repos/harvard-lil/capstone/pulls/comments{/number}","comments_url":"https://api.github.com/repos/harvard-lil/capstone/issues/534/comments","statuses_url":"https://api.github.com/repos/harvard-lil/capstone/statuses/16b1816a7cb438960e279a870534614aa40350e8","head":{"label":"jcushman:ngrams","ref":"ngrams","sha":"16b1816a7cb438960e279a870534614aa40350e8","user":{"login":"jcushman","id":376272,"node_id":"MDQ6VXNlcjM3NjI3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/376272?v=4","gravatar_id":"","url":"https://api.github.com/users/jcushman","html_url":"https://github.com/jcushman","followers_url":"https://api.github.com/users/jcushman/followers","following_url":"https://api.github.com/users/jcushman/following{/other_user}","gists_url":"https://api.github.com/users/jcushman/gists{/gist_id}","starred_url":"https://api.github.com/users/jcushman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcushman/subscriptions","organizations_url":"https://api.github.com/users/jcushman/orgs","repos_url":"https://api.github.com/users/jcushman/repos","events_url":"https://api.github.com/users/jcushman/events{/privacy}","received_events_url":"https://api.github.com/users/jcushman/received_events","type":"User","site_admin":false},"repo":{"id":95126022,"node_id":"MDEwOlJlcG9zaXRvcnk5NTEyNjAyMg==","name":"capstone","full_name":"jcushman/capstone","private":false,"owner":{"login":"jcushman","id":376272,"node_id":"MDQ6VXNlcjM3NjI3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/376272?v=4","gravatar_id":"","url":"https://api.github.com/users/jcushman","html_url":"https://github.com/jcushman","followers_url":"https://api.github.com/users/jcushman/followers","following_url":"https://api.github.com/users/jcushman/following{/other_user}","gists_url":"https://api.github.com/users/jcushman/gists{/gist_id}","starred_url":"https://api.github.com/users/jcushman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcushman/subscriptions","organizations_url":"https://api.github.com/users/jcushman/orgs","repos_url":"https://api.github.com/users/jcushman/repos","events_url":"https://api.github.com/users/jcushman/events{/privacy}","received_events_url":"https://api.github.com/users/jcushman/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jcushman/capstone","description":"CAP database scripts.","fork":true,"url":"https://api.github.com/repos/jcushman/capstone","forks_url":"https://api.github.com/repos/jcushman/capstone/forks","keys_url":"https://api.github.com/repos/jcushman/capstone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jcushman/capstone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jcushman/capstone/teams","hooks_url":"https://api.github.com/repos/jcushman/capstone/hooks","issue_events_url":"https://api.github.com/repos/jcushman/capstone/issues/events{/number}","events_url":"https://api.github.com/repos/jcushman/capstone/events","assignees_url":"https://api.github.com/repos/jcushman/capstone/assignees{/user}","branches_url":"https://api.github.com/repos/jcushman/capstone/branches{/branch}","tags_url":"https://api.github.com/repos/jcushman/capstone/tags","blobs_url":"https://api.github.com/repos/jcushman/capstone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jcushman/capstone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jcushman/capstone/git/refs{/sha}","trees_url":"https://api.github.com/repos/jcushman/capstone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jcushman/capstone/statuses/{sha}","languages_url":"https://api.github.com/repos/jcushman/capstone/languages","stargazers_url":"https://api.github.com/repos/jcushman/capstone/stargazers","contributors_url":"https://api.github.com/repos/jcushman/capstone/contributors","subscribers_url":"https://api.github.com/repos/jcushman/capstone/subscribers","subscription_url":"https://api.github.com/repos/jcushman/capstone/subscription","commits_url":"https://api.github.com/repos/jcushman/capstone/commits{/sha}","git_commits_url":"https://api.github.com/repos/jcushman/capstone/git/commits{/sha}","comments_url":"https://api.github.com/repos/jcushman/capstone/comments{/number}","issue_comment_url":"https://api.github.com/repos/jcushman/capstone/issues/comments{/number}","contents_url":"https://api.github.com/repos/jcushman/capstone/contents/{+path}","compare_url":"https://api.github.com/repos/jcushman/capstone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jcushman/capstone/merges","archive_url":"https://api.github.com/repos/jcushman/capstone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jcushman/capstone/downloads","issues_url":"https://api.github.com/repos/jcushman/capstone/issues{/number}","pulls_url":"https://api.github.com/repos/jcushman/capstone/pulls{/number}","milestones_url":"https://api.github.com/repos/jcushman/capstone/milestones{/number}","notifications_url":"https://api.github.com/repos/jcushman/capstone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jcushman/capstone/labels{/name}","releases_url":"https://api.github.com/repos/jcushman/capstone/releases{/id}","deployments_url":"https://api.github.com/repos/jcushman/capstone/deployments","created_at":"2017-06-22T14:46:23Z","updated_at":"2018-04-24T15:01:04Z","pushed_at":"2018-10-01T19:08:23Z","git_url":"git://github.com/jcushman/capstone.git","ssh_url":"git@github.com:jcushman/capstone.git","clone_url":"https://github.com/jcushman/capstone.git","svn_url":"https://github.com/jcushman/capstone","homepage":null,"size":88610,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"harvard-lil:develop","ref":"develop","sha":"ee96988f33ab7b08a8ace8cd4a3812b4573da9db","user":{"login":"harvard-lil","id":857200,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NzIwMA==","avatar_url":"https://avatars0.githubusercontent.com/u/857200?v=4","gravatar_id":"","url":"https://api.github.com/users/harvard-lil","html_url":"https://github.com/harvard-lil","followers_url":"https://api.github.com/users/harvard-lil/followers","following_url":"https://api.github.com/users/harvard-lil/following{/other_user}","gists_url":"https://api.github.com/users/harvard-lil/gists{/gist_id}","starred_url":"https://api.github.com/users/harvard-lil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvard-lil/subscriptions","organizations_url":"https://api.github.com/users/harvard-lil/orgs","repos_url":"https://api.github.com/users/harvard-lil/repos","events_url":"https://api.github.com/users/harvard-lil/events{/privacy}","received_events_url":"https://api.github.com/users/harvard-lil/received_events","type":"Organization","site_admin":false},"repo":{"id":82964836,"node_id":"MDEwOlJlcG9zaXRvcnk4Mjk2NDgzNg==","name":"capstone","full_name":"harvard-lil/capstone","private":false,"owner":{"login":"harvard-lil","id":857200,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NzIwMA==","avatar_url":"https://avatars0.githubusercontent.com/u/857200?v=4","gravatar_id":"","url":"https://api.github.com/users/harvard-lil","html_url":"https://github.com/harvard-lil","followers_url":"https://api.github.com/users/harvard-lil/followers","following_url":"https://api.github.com/users/harvard-lil/following{/other_user}","gists_url":"https://api.github.com/users/harvard-lil/gists{/gist_id}","starred_url":"https://api.github.com/users/harvard-lil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvard-lil/subscriptions","organizations_url":"https://api.github.com/users/harvard-lil/orgs","repos_url":"https://api.github.com/users/harvard-lil/repos","events_url":"https://api.github.com/users/harvard-lil/events{/privacy}","received_events_url":"https://api.github.com/users/harvard-lil/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/harvard-lil/capstone","description":"CAP database scripts.","fork":false,"url":"https://api.github.com/repos/harvard-lil/capstone","forks_url":"https://api.github.com/repos/harvard-lil/capstone/forks","keys_url":"https://api.github.com/repos/harvard-lil/capstone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harvard-lil/capstone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harvard-lil/capstone/teams","hooks_url":"https://api.github.com/repos/harvard-lil/capstone/hooks","issue_events_url":"https://api.github.com/repos/harvard-lil/capstone/issues/events{/number}","events_url":"https://api.github.com/repos/harvard-lil/capstone/events","assignees_url":"https://api.github.com/repos/harvard-lil/capstone/assignees{/user}","branches_url":"https://api.github.com/repos/harvard-lil/capstone/branches{/branch}","tags_url":"https://api.github.com/repos/harvard-lil/capstone/tags","blobs_url":"https://api.github.com/repos/harvard-lil/capstone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harvard-lil/capstone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harvard-lil/capstone/git/refs{/sha}","trees_url":"https://api.github.com/repos/harvard-lil/capstone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harvard-lil/capstone/statuses/{sha}","languages_url":"https://api.github.com/repos/harvard-lil/capstone/languages","stargazers_url":"https://api.github.com/repos/harvard-lil/capstone/stargazers","contributors_url":"https://api.github.com/repos/harvard-lil/capstone/contributors","subscribers_url":"https://api.github.com/repos/harvard-lil/capstone/subscribers","subscription_url":"https://api.github.com/repos/harvard-lil/capstone/subscription","commits_url":"https://api.github.com/repos/harvard-lil/capstone/commits{/sha}","git_commits_url":"https://api.github.com/repos/harvard-lil/capstone/git/commits{/sha}","comments_url":"https://api.github.com/repos/harvard-lil/capstone/comments{/number}","issue_comment_url":"https://api.github.com/repos/harvard-lil/capstone/issues/comments{/number}","contents_url":"https://api.github.com/repos/harvard-lil/capstone/contents/{+path}","compare_url":"https://api.github.com/repos/harvard-lil/capstone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harvard-lil/capstone/merges","archive_url":"https://api.github.com/repos/harvard-lil/capstone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harvard-lil/capstone/downloads","issues_url":"https://api.github.com/repos/harvard-lil/capstone/issues{/number}","pulls_url":"https://api.github.com/repos/harvard-lil/capstone/pulls{/number}","milestones_url":"https://api.github.com/repos/harvard-lil/capstone/milestones{/number}","notifications_url":"https://api.github.com/repos/harvard-lil/capstone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harvard-lil/capstone/labels{/name}","releases_url":"https://api.github.com/repos/harvard-lil/capstone/releases{/id}","deployments_url":"https://api.github.com/repos/harvard-lil/capstone/deployments","created_at":"2017-02-23T19:44:44Z","updated_at":"2018-10-01T13:48:11Z","pushed_at":"2018-10-01T17:18:38Z","git_url":"git://github.com/harvard-lil/capstone.git","ssh_url":"git@github.com:harvard-lil/capstone.git","clone_url":"https://github.com/harvard-lil/capstone.git","svn_url":"https://github.com/harvard-lil/capstone","homepage":null,"size":88737,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":96,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":6,"open_issues":96,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/harvard-lil/capstone/pulls/534"},"html":{"href":"https://github.com/harvard-lil/capstone/pull/534"},"issue":{"href":"https://api.github.com/repos/harvard-lil/capstone/issues/534"},"comments":{"href":"https://api.github.com/repos/harvard-lil/capstone/issues/534/comments"},"review_comments":{"href":"https://api.github.com/repos/harvard-lil/capstone/pulls/534/comments"},"review_comment":{"href":"https://api.github.com/repos/harvard-lil/capstone/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/harvard-lil/capstone/pulls/534/commits"},"statuses":{"href":"https://api.github.com/repos/harvard-lil/capstone/statuses/16b1816a7cb438960e279a870534614aa40350e8"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":494,"deletions":13,"changed_files":19}}
{"actor":{"display_login":"jcushman"}}