{"action":"created","comment":{"url":"https://api.github.com/repos/socrata/arcs/pulls/comments/64962243","id":64962243,"diff_hunk":"@@ -0,0 +1,120 @@\n+import logging\n+import requests\n+from frozendict import frozendict\n+\n+from collect_domain_query_data import lang_filter\n+\n+LOGGER = logging.getLogger(__name__)\n+\n+\n+class Query(object):\n+    @property\n+    def text(self):\n+        return self._text\n+\n+    @classmethod\n+    def from_query_str(cls, q):\n+        parts = q.split('=')\n+        return FacetSearch(parts[0], parts[1]) if len(parts) == 2 else KeywordSearch(q)\n+\n+    def to_query_params(self):\n+        pass\n+\n+\n+class KeywordSearch(Query):\n+    def __init__(self, text):\n+        self._text = text\n+\n+    def to_query_params(self):\n+        return {\"q\": self._text}\n+\n+    def __str__(self):\n+        return self.text\n+\n+    __repr__ = __str__\n+\n+\n+def prepare_facet(facet):\n+    if facet == \"category\":\n+        prepared = \"categories\"\n+    else:\n+        prepared = facet\n+\n+    return prepared\n+\n+\n+class FacetSearch(Query):\n+    def __init__(self, facet, text):\n+        super(Query, self)\n+        self._facet = facet\n+        self._text = text\n+\n+    @property\n+    def facet(self):\n+        return self._facet\n+\n+    def to_query_params(self):\n+        return {prepare_facet(self.facet): self.text}\n+\n+    def __str__(self):\n+        return \"{}={}\".format(self.facet, self.text)\n+\n+    __repr__ = __str__\n+\n+\n+def get_cetera_results(domain_query_pairs, cetera_host, cetera_port,\n+                       num_results=10, cetera_params=None,\n+                       filter_too_few_results=False):\n+    \"\"\"\n+    Get the top n=num_results catalog search results from Cetera for each\n+    (domain, query) pair in domain_query_pairs.\n+\n+    Args:\n+        domain_query_pairs (Iterable[(str, Query)]): An iterable of domain-query pairs\n+        cetera_host (str): The Cetera hostname\n+        cetera_port (int): The port on which to make requests to Cetera\n+        num_results (int): The number of results to fetch for each query\n+        cetera_params (Dict[Any, Any]): Optional, additional query parameters for Cetera","path":"arcs/cetera.py","position":77,"original_position":77,"commit_id":"e4c76c96a9efaa20a7fd0455a918009555c73dc6","original_commit_id":"e4c76c96a9efaa20a7fd0455a918009555c73dc6","user":{"login":"rlvoyer","id":172413,"avatar_url":"https://avatars.githubusercontent.com/u/172413?v=3","gravatar_id":"","url":"https://api.github.com/users/rlvoyer","html_url":"https://github.com/rlvoyer","followers_url":"https://api.github.com/users/rlvoyer/followers","following_url":"https://api.github.com/users/rlvoyer/following{/other_user}","gists_url":"https://api.github.com/users/rlvoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/rlvoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlvoyer/subscriptions","organizations_url":"https://api.github.com/users/rlvoyer/orgs","repos_url":"https://api.github.com/users/rlvoyer/repos","events_url":"https://api.github.com/users/rlvoyer/events{/privacy}","received_events_url":"https://api.github.com/users/rlvoyer/received_events","type":"User","site_admin":false},"body":"It appears that way, but did you check out Python 3 type annotations? As I mentioned previously, there is no comprehensive guide on the right way to do this, so I'm synthesizing the Google Python styleguide and the docs on the Python 3 type annotations (https://docs.python.org/3/library/typing.html). I find it awesomely readable.","created_at":"2016-05-27T20:27:49Z","updated_at":"2016-05-27T20:27:49Z","html_url":"https://github.com/socrata/arcs/pull/37#discussion_r64962243","pull_request_url":"https://api.github.com/repos/socrata/arcs/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/socrata/arcs/pulls/comments/64962243"},"html":{"href":"https://github.com/socrata/arcs/pull/37#discussion_r64962243"},"pull_request":{"href":"https://api.github.com/repos/socrata/arcs/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/socrata/arcs/pulls/37","id":70782690,"html_url":"https://github.com/socrata/arcs/pull/37","diff_url":"https://github.com/socrata/arcs/pull/37.diff","patch_url":"https://github.com/socrata/arcs/pull/37.patch","issue_url":"https://api.github.com/repos/socrata/arcs/issues/37","number":37,"state":"open","locked":false,"title":"Make Python3 friendly and support category facet relevance","user":{"login":"rlvoyer","id":172413,"avatar_url":"https://avatars.githubusercontent.com/u/172413?v=3","gravatar_id":"","url":"https://api.github.com/users/rlvoyer","html_url":"https://github.com/rlvoyer","followers_url":"https://api.github.com/users/rlvoyer/followers","following_url":"https://api.github.com/users/rlvoyer/following{/other_user}","gists_url":"https://api.github.com/users/rlvoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/rlvoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlvoyer/subscriptions","organizations_url":"https://api.github.com/users/rlvoyer/orgs","repos_url":"https://api.github.com/users/rlvoyer/repos","events_url":"https://api.github.com/users/rlvoyer/events{/privacy}","received_events_url":"https://api.github.com/users/rlvoyer/received_events","type":"User","site_admin":false},"body":"This changeset includes modifications to make arcs work in Python3. Additionally, and more importantly, it adds support for the category/search facet relevance jobs (specifically, to allow us to compare relevance on category facet queries w/ old and new clads).","created_at":"2016-05-19T23:41:43Z","updated_at":"2016-05-27T20:27:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e4bc6e1bdcf51b449747b4a083c783669ffa31e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/socrata/arcs/pulls/37/commits","review_comments_url":"https://api.github.com/repos/socrata/arcs/pulls/37/comments","review_comment_url":"https://api.github.com/repos/socrata/arcs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/socrata/arcs/issues/37/comments","statuses_url":"https://api.github.com/repos/socrata/arcs/statuses/e4c76c96a9efaa20a7fd0455a918009555c73dc6","head":{"label":"socrata:robert/python3","ref":"robert/python3","sha":"e4c76c96a9efaa20a7fd0455a918009555c73dc6","user":{"login":"socrata","id":57695,"avatar_url":"https://avatars.githubusercontent.com/u/57695?v=3","gravatar_id":"","url":"https://api.github.com/users/socrata","html_url":"https://github.com/socrata","followers_url":"https://api.github.com/users/socrata/followers","following_url":"https://api.github.com/users/socrata/following{/other_user}","gists_url":"https://api.github.com/users/socrata/gists{/gist_id}","starred_url":"https://api.github.com/users/socrata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socrata/subscriptions","organizations_url":"https://api.github.com/users/socrata/orgs","repos_url":"https://api.github.com/users/socrata/repos","events_url":"https://api.github.com/users/socrata/events{/privacy}","received_events_url":"https://api.github.com/users/socrata/received_events","type":"Organization","site_admin":false},"repo":{"id":39459354,"name":"arcs","full_name":"socrata/arcs","owner":{"login":"socrata","id":57695,"avatar_url":"https://avatars.githubusercontent.com/u/57695?v=3","gravatar_id":"","url":"https://api.github.com/users/socrata","html_url":"https://github.com/socrata","followers_url":"https://api.github.com/users/socrata/followers","following_url":"https://api.github.com/users/socrata/following{/other_user}","gists_url":"https://api.github.com/users/socrata/gists{/gist_id}","starred_url":"https://api.github.com/users/socrata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socrata/subscriptions","organizations_url":"https://api.github.com/users/socrata/orgs","repos_url":"https://api.github.com/users/socrata/repos","events_url":"https://api.github.com/users/socrata/events{/privacy}","received_events_url":"https://api.github.com/users/socrata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/socrata/arcs","description":"A Python library for Assessing Relevance of our Catalog Search system.","fork":false,"url":"https://api.github.com/repos/socrata/arcs","forks_url":"https://api.github.com/repos/socrata/arcs/forks","keys_url":"https://api.github.com/repos/socrata/arcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/socrata/arcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/socrata/arcs/teams","hooks_url":"https://api.github.com/repos/socrata/arcs/hooks","issue_events_url":"https://api.github.com/repos/socrata/arcs/issues/events{/number}","events_url":"https://api.github.com/repos/socrata/arcs/events","assignees_url":"https://api.github.com/repos/socrata/arcs/assignees{/user}","branches_url":"https://api.github.com/repos/socrata/arcs/branches{/branch}","tags_url":"https://api.github.com/repos/socrata/arcs/tags","blobs_url":"https://api.github.com/repos/socrata/arcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/socrata/arcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/socrata/arcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/socrata/arcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/socrata/arcs/statuses/{sha}","languages_url":"https://api.github.com/repos/socrata/arcs/languages","stargazers_url":"https://api.github.com/repos/socrata/arcs/stargazers","contributors_url":"https://api.github.com/repos/socrata/arcs/contributors","subscribers_url":"https://api.github.com/repos/socrata/arcs/subscribers","subscription_url":"https://api.github.com/repos/socrata/arcs/subscription","commits_url":"https://api.github.com/repos/socrata/arcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/socrata/arcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/socrata/arcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/socrata/arcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/socrata/arcs/contents/{+path}","compare_url":"https://api.github.com/repos/socrata/arcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/socrata/arcs/merges","archive_url":"https://api.github.com/repos/socrata/arcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/socrata/arcs/downloads","issues_url":"https://api.github.com/repos/socrata/arcs/issues{/number}","pulls_url":"https://api.github.com/repos/socrata/arcs/pulls{/number}","milestones_url":"https://api.github.com/repos/socrata/arcs/milestones{/number}","notifications_url":"https://api.github.com/repos/socrata/arcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/socrata/arcs/labels{/name}","releases_url":"https://api.github.com/repos/socrata/arcs/releases{/id}","deployments_url":"https://api.github.com/repos/socrata/arcs/deployments","created_at":"2015-07-21T17:17:39Z","updated_at":"2016-01-27T00:56:25Z","pushed_at":"2016-05-26T05:11:42Z","git_url":"git://github.com/socrata/arcs.git","ssh_url":"git@github.com:socrata/arcs.git","clone_url":"https://github.com/socrata/arcs.git","svn_url":"https://github.com/socrata/arcs","homepage":null,"size":394,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":0,"default_branch":"master"}},"base":{"label":"socrata:master","ref":"master","sha":"0480e589cd4ed221e40e6059f48b4e568610d97f","user":{"login":"socrata","id":57695,"avatar_url":"https://avatars.githubusercontent.com/u/57695?v=3","gravatar_id":"","url":"https://api.github.com/users/socrata","html_url":"https://github.com/socrata","followers_url":"https://api.github.com/users/socrata/followers","following_url":"https://api.github.com/users/socrata/following{/other_user}","gists_url":"https://api.github.com/users/socrata/gists{/gist_id}","starred_url":"https://api.github.com/users/socrata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socrata/subscriptions","organizations_url":"https://api.github.com/users/socrata/orgs","repos_url":"https://api.github.com/users/socrata/repos","events_url":"https://api.github.com/users/socrata/events{/privacy}","received_events_url":"https://api.github.com/users/socrata/received_events","type":"Organization","site_admin":false},"repo":{"id":39459354,"name":"arcs","full_name":"socrata/arcs","owner":{"login":"socrata","id":57695,"avatar_url":"https://avatars.githubusercontent.com/u/57695?v=3","gravatar_id":"","url":"https://api.github.com/users/socrata","html_url":"https://github.com/socrata","followers_url":"https://api.github.com/users/socrata/followers","following_url":"https://api.github.com/users/socrata/following{/other_user}","gists_url":"https://api.github.com/users/socrata/gists{/gist_id}","starred_url":"https://api.github.com/users/socrata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socrata/subscriptions","organizations_url":"https://api.github.com/users/socrata/orgs","repos_url":"https://api.github.com/users/socrata/repos","events_url":"https://api.github.com/users/socrata/events{/privacy}","received_events_url":"https://api.github.com/users/socrata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/socrata/arcs","description":"A Python library for Assessing Relevance of our Catalog Search system.","fork":false,"url":"https://api.github.com/repos/socrata/arcs","forks_url":"https://api.github.com/repos/socrata/arcs/forks","keys_url":"https://api.github.com/repos/socrata/arcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/socrata/arcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/socrata/arcs/teams","hooks_url":"https://api.github.com/repos/socrata/arcs/hooks","issue_events_url":"https://api.github.com/repos/socrata/arcs/issues/events{/number}","events_url":"https://api.github.com/repos/socrata/arcs/events","assignees_url":"https://api.github.com/repos/socrata/arcs/assignees{/user}","branches_url":"https://api.github.com/repos/socrata/arcs/branches{/branch}","tags_url":"https://api.github.com/repos/socrata/arcs/tags","blobs_url":"https://api.github.com/repos/socrata/arcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/socrata/arcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/socrata/arcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/socrata/arcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/socrata/arcs/statuses/{sha}","languages_url":"https://api.github.com/repos/socrata/arcs/languages","stargazers_url":"https://api.github.com/repos/socrata/arcs/stargazers","contributors_url":"https://api.github.com/repos/socrata/arcs/contributors","subscribers_url":"https://api.github.com/repos/socrata/arcs/subscribers","subscription_url":"https://api.github.com/repos/socrata/arcs/subscription","commits_url":"https://api.github.com/repos/socrata/arcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/socrata/arcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/socrata/arcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/socrata/arcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/socrata/arcs/contents/{+path}","compare_url":"https://api.github.com/repos/socrata/arcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/socrata/arcs/merges","archive_url":"https://api.github.com/repos/socrata/arcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/socrata/arcs/downloads","issues_url":"https://api.github.com/repos/socrata/arcs/issues{/number}","pulls_url":"https://api.github.com/repos/socrata/arcs/pulls{/number}","milestones_url":"https://api.github.com/repos/socrata/arcs/milestones{/number}","notifications_url":"https://api.github.com/repos/socrata/arcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/socrata/arcs/labels{/name}","releases_url":"https://api.github.com/repos/socrata/arcs/releases{/id}","deployments_url":"https://api.github.com/repos/socrata/arcs/deployments","created_at":"2015-07-21T17:17:39Z","updated_at":"2016-01-27T00:56:25Z","pushed_at":"2016-05-26T05:11:42Z","git_url":"git://github.com/socrata/arcs.git","ssh_url":"git@github.com:socrata/arcs.git","clone_url":"https://github.com/socrata/arcs.git","svn_url":"https://github.com/socrata/arcs","homepage":null,"size":394,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/socrata/arcs/pulls/37"},"html":{"href":"https://github.com/socrata/arcs/pull/37"},"issue":{"href":"https://api.github.com/repos/socrata/arcs/issues/37"},"comments":{"href":"https://api.github.com/repos/socrata/arcs/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/socrata/arcs/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/socrata/arcs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/socrata/arcs/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/socrata/arcs/statuses/e4c76c96a9efaa20a7fd0455a918009555c73dc6"}}}}
{"actor":{"display_login":"rlvoyer"}}