{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/60403463","id":60403463,"diff_hunk":"@@ -0,0 +1,96 @@\n+#|\n+exec /usr/bin/env sbcl --noinform --quit --load \"$0\" --end-toplevel-options \"$@\"\n+|#\n+\n+;;; This script clusterizes postcodes from the taginfo database and\n+;;; prints information about clusters.\n+\n+;;; Silently loads sqlite.\n+(with-open-file (*standard-output* \"/dev/null\"\n+                                   :direction :output\n+                                   :if-exists :supersede)\n+  (ql:quickload \"sqlite\"))\n+\n+(defstruct cluster\n+  \"A cluster of postcodes with the same pattern, i.e.  all six-digirs\n+   postcodes or all four-digits-two-letters postcodes.\"\n+  (key \"\") (num-samples 0) (samples (list)))\n+\n+(defun add-sample (cluster sample)\n+  \"Adds a postcode sample to a cluster of samples.\"\n+  (push sample (slot-value cluster 'samples))\n+  (incf (slot-value cluster 'num-samples)))\n+\n+(defparameter *seps* '(#\\Space #\\Tab #\\Newline #\\Backspace #\\Return #\\Rubout #\\Linefeed #\\\"))\n+\n+(defun trim (string)\n+  \"Removes leading and trailing garbage from a string.\"\n+  (string-trim *seps* string))\n+\n+(defun get-postcode-pattern (postcode)\n+  \"Simplifies postcode in a following way:\n+   * all letters are replaced by 'a'\n+   * all digits are replaced by '0'\n+   * other characters are left as-is\n+  \"\n+  (map 'string #'(lambda (c) (cond ((alpha-char-p c) #\\a)\n+                                   ((digit-char-p c) #\\0)\n+                                   (T c)))\n+       postcode))\n+\n+(defun get-pattern-clusters (postcodes)\n+  \"Constructs a list of clusters by a list of postcodes.\"\n+  (let ((table (make-hash-table :test #'equal))\n+        (clusters (list)))\n+    (dolist (postcode postcodes)\n+      (let* ((trimmed-postcode (trim postcode))\n+             (pattern (get-postcode-pattern trimmed-postcode)))\n+        (unless (gethash pattern table)\n+          (setf (gethash pattern table) (make-cluster :key pattern)))\n+        (add-sample (gethash pattern table) trimmed-postcode)))","path":"search/search_quality/clusterize-postcodes.lisp","position":50,"original_position":50,"commit_id":"28d4f15e92b429f34235e33b2a99bf074544dde1","original_commit_id":"28d4f15e92b429f34235e33b2a99bf074544dde1","user":{"login":"mgsergio","id":6658987,"avatar_url":"https://avatars.githubusercontent.com/u/6658987?v=3","gravatar_id":"","url":"https://api.github.com/users/mgsergio","html_url":"https://github.com/mgsergio","followers_url":"https://api.github.com/users/mgsergio/followers","following_url":"https://api.github.com/users/mgsergio/following{/other_user}","gists_url":"https://api.github.com/users/mgsergio/gists{/gist_id}","starred_url":"https://api.github.com/users/mgsergio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgsergio/subscriptions","organizations_url":"https://api.github.com/users/mgsergio/orgs","repos_url":"https://api.github.com/users/mgsergio/repos","events_url":"https://api.github.com/users/mgsergio/events{/privacy}","received_events_url":"https://api.github.com/users/mgsergio/received_events","type":"User","site_admin":false},"body":"Можно ли \"залетить\" '''(gethash pattern table)'''?","created_at":"2016-04-20T13:10:49Z","updated_at":"2016-04-20T13:10:49Z","html_url":"https://github.com/mapsme/omim/pull/2934#discussion_r60403463","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/2934","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/60403463"},"html":{"href":"https://github.com/mapsme/omim/pull/2934#discussion_r60403463"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2934"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/2934","id":67180326,"html_url":"https://github.com/mapsme/omim/pull/2934","diff_url":"https://github.com/mapsme/omim/pull/2934.diff","patch_url":"https://github.com/mapsme/omim/pull/2934.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/2934","number":2934,"state":"open","locked":false,"title":"[search] Added postcodes-clusterizer script.","user":{"login":"ygorshenin","id":454567,"avatar_url":"https://avatars.githubusercontent.com/u/454567?v=3","gravatar_id":"","url":"https://api.github.com/users/ygorshenin","html_url":"https://github.com/ygorshenin","followers_url":"https://api.github.com/users/ygorshenin/followers","following_url":"https://api.github.com/users/ygorshenin/following{/other_user}","gists_url":"https://api.github.com/users/ygorshenin/gists{/gist_id}","starred_url":"https://api.github.com/users/ygorshenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygorshenin/subscriptions","organizations_url":"https://api.github.com/users/ygorshenin/orgs","repos_url":"https://api.github.com/users/ygorshenin/repos","events_url":"https://api.github.com/users/ygorshenin/events{/privacy}","received_events_url":"https://api.github.com/users/ygorshenin/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-20T12:47:44Z","updated_at":"2016-04-20T13:10:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6cc5d55a4ca141811bfabb1a31c75796e58d32eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/2934/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/2934/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/2934/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/28d4f15e92b429f34235e33b2a99bf074544dde1","head":{"label":"ygorshenin:postcodes-clusterizer","ref":"postcodes-clusterizer","sha":"28d4f15e92b429f34235e33b2a99bf074544dde1","user":{"login":"ygorshenin","id":454567,"avatar_url":"https://avatars.githubusercontent.com/u/454567?v=3","gravatar_id":"","url":"https://api.github.com/users/ygorshenin","html_url":"https://github.com/ygorshenin","followers_url":"https://api.github.com/users/ygorshenin/followers","following_url":"https://api.github.com/users/ygorshenin/following{/other_user}","gists_url":"https://api.github.com/users/ygorshenin/gists{/gist_id}","starred_url":"https://api.github.com/users/ygorshenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygorshenin/subscriptions","organizations_url":"https://api.github.com/users/ygorshenin/orgs","repos_url":"https://api.github.com/users/ygorshenin/repos","events_url":"https://api.github.com/users/ygorshenin/events{/privacy}","received_events_url":"https://api.github.com/users/ygorshenin/received_events","type":"User","site_admin":false},"repo":{"id":43427948,"name":"omim","full_name":"ygorshenin/omim","owner":{"login":"ygorshenin","id":454567,"avatar_url":"https://avatars.githubusercontent.com/u/454567?v=3","gravatar_id":"","url":"https://api.github.com/users/ygorshenin","html_url":"https://github.com/ygorshenin","followers_url":"https://api.github.com/users/ygorshenin/followers","following_url":"https://api.github.com/users/ygorshenin/following{/other_user}","gists_url":"https://api.github.com/users/ygorshenin/gists{/gist_id}","starred_url":"https://api.github.com/users/ygorshenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygorshenin/subscriptions","organizations_url":"https://api.github.com/users/ygorshenin/orgs","repos_url":"https://api.github.com/users/ygorshenin/repos","events_url":"https://api.github.com/users/ygorshenin/events{/privacy}","received_events_url":"https://api.github.com/users/ygorshenin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ygorshenin/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/ygorshenin/omim","forks_url":"https://api.github.com/repos/ygorshenin/omim/forks","keys_url":"https://api.github.com/repos/ygorshenin/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ygorshenin/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ygorshenin/omim/teams","hooks_url":"https://api.github.com/repos/ygorshenin/omim/hooks","issue_events_url":"https://api.github.com/repos/ygorshenin/omim/issues/events{/number}","events_url":"https://api.github.com/repos/ygorshenin/omim/events","assignees_url":"https://api.github.com/repos/ygorshenin/omim/assignees{/user}","branches_url":"https://api.github.com/repos/ygorshenin/omim/branches{/branch}","tags_url":"https://api.github.com/repos/ygorshenin/omim/tags","blobs_url":"https://api.github.com/repos/ygorshenin/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ygorshenin/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ygorshenin/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/ygorshenin/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ygorshenin/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/ygorshenin/omim/languages","stargazers_url":"https://api.github.com/repos/ygorshenin/omim/stargazers","contributors_url":"https://api.github.com/repos/ygorshenin/omim/contributors","subscribers_url":"https://api.github.com/repos/ygorshenin/omim/subscribers","subscription_url":"https://api.github.com/repos/ygorshenin/omim/subscription","commits_url":"https://api.github.com/repos/ygorshenin/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/ygorshenin/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/ygorshenin/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/ygorshenin/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/ygorshenin/omim/contents/{+path}","compare_url":"https://api.github.com/repos/ygorshenin/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ygorshenin/omim/merges","archive_url":"https://api.github.com/repos/ygorshenin/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ygorshenin/omim/downloads","issues_url":"https://api.github.com/repos/ygorshenin/omim/issues{/number}","pulls_url":"https://api.github.com/repos/ygorshenin/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/ygorshenin/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/ygorshenin/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ygorshenin/omim/labels{/name}","releases_url":"https://api.github.com/repos/ygorshenin/omim/releases{/id}","deployments_url":"https://api.github.com/repos/ygorshenin/omim/deployments","created_at":"2015-09-30T10:56:11Z","updated_at":"2016-03-24T14:50:25Z","pushed_at":"2016-04-20T12:47:25Z","git_url":"git://github.com/ygorshenin/omim.git","ssh_url":"git@github.com:ygorshenin/omim.git","clone_url":"https://github.com/ygorshenin/omim.git","svn_url":"https://github.com/ygorshenin/omim","homepage":null,"size":2288903,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mapsme:master","ref":"master","sha":"767b0bd1c7668fa1f943de382418ea7d20d3aa98","user":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mapsme/omim/deployments","created_at":"2015-09-20T02:57:13Z","updated_at":"2016-04-20T12:28:12Z","pushed_at":"2016-04-20T12:50:06Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":null,"size":2383317,"stargazers_count":1739,"watchers_count":1739,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":263,"mirror_url":null,"open_issues_count":150,"forks":263,"open_issues":150,"watchers":1739,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2934"},"html":{"href":"https://github.com/mapsme/omim/pull/2934"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/2934"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/2934/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2934/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2934/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/28d4f15e92b429f34235e33b2a99bf074544dde1"}}}}