{"action":"created","comment":{"url":"https://api.github.com/repos/google/personfinder/pulls/comments/39357217","id":39357217,"diff_hunk":"@@ -0,0 +1,80 @@\n+import jautils\n+\n+from unidecode import unidecode\n+from google.appengine.api import memcache\n+\n+import re\n+import logging\n+\n+def read_dictionary(file_name):\n+    dictionary = {}\n+    for line in open(file_name, 'r'):\n+        kanji, hiragana = line[:-1].split('\\t')\n+        dictionary[kanji.decode('utf-8')] = hiragana.decode('utf-8')\n+    return dictionary\n+\n+JAPANESE_NAME_DICTIONARY = read_dictionary('japanese_name_dict.txt')\n+JAPANESE_LOCATION_DICTIONARY = read_dictionary('jp_location_dict.txt')\n+\n+def romanize_word(word):\n+    \"\"\"\n+    This method romanize all languages by unidecode.\n+    If word is hiragana or katakana, it is romanized by jautils.\n+    Args:\n+        word: should be script varianted\n+    Returns:\n+        script varianted word\n+    \"\"\"\n+    if not word:\n+        return word\n+\n+    if jautils.should_normalize(word):\n+        hiragana_word = jautils.normalize(word)\n+        return jautils.hiragana_to_romaji(hiragana_word)\n+    romanized_word = unidecode(word)\n+    return romanized_word\n+\n+\n+def romanize_japanese_name_by_name_dict(word):\n+    \"\"\"\n+    This method romanize japanese name by using name dictionary.\n+    If word isn't found in dictionary, this method doesn't\n+    apply romanize.\n+    \"\"\"\n+    if not word:\n+        return word\n+\n+    if word in JAPANESE_NAME_DICTIONARY:\n+        yomigana = (JAPANESE_NAME_DICTIONARY[word])\n+        return jautils.hiragana_to_romaji(yomigana)\n+\n+    return word\n+\n+def romanize_japanese_location(word):\n+    \"\"\"\n+    This method romanize japanese name by using name dictionary.\n+    If word isn't found in dictionary, this method doesn't\n+    apply romanize.\n+    \"\"\"\n+    if not word:\n+        return word\n+\n+    if word in JAPANESE_LOCATION_DICTIONARY:\n+        yomigana = (JAPANESE_LOCATION_DICTIONARY[word])\n+        return jautils.hiragana_to_romaji(yomigana)\n+\n+    return word\n+\n+\n+def romanize_text(query_txt):\n+    \"\"\"\n+    Applies to script variant to each query_txt.","path":"app/script_variant.py","position":71,"original_position":71,"commit_id":"ff0770ea983b2840ec705805fa8d22b8b01a3d09","original_commit_id":"ff0770ea983b2840ec705805fa8d22b8b01a3d09","user":{"login":"skywhale","id":872395,"avatar_url":"https://avatars.githubusercontent.com/u/872395?v=3","gravatar_id":"","url":"https://api.github.com/users/skywhale","html_url":"https://github.com/skywhale","followers_url":"https://api.github.com/users/skywhale/followers","following_url":"https://api.github.com/users/skywhale/following{/other_user}","gists_url":"https://api.github.com/users/skywhale/gists{/gist_id}","starred_url":"https://api.github.com/users/skywhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skywhale/subscriptions","organizations_url":"https://api.github.com/users/skywhale/orgs","repos_url":"https://api.github.com/users/skywhale/repos","events_url":"https://api.github.com/users/skywhale/events{/privacy}","received_events_url":"https://api.github.com/users/skywhale/received_events","type":"User","site_admin":false},"body":"Applies romanization to each work in query_text","created_at":"2015-09-14T02:19:09Z","updated_at":"2015-09-14T02:19:09Z","html_url":"https://github.com/google/personfinder/pull/161#discussion_r39357217","pull_request_url":"https://api.github.com/repos/google/personfinder/pulls/161","_links":{"self":{"href":"https://api.github.com/repos/google/personfinder/pulls/comments/39357217"},"html":{"href":"https://github.com/google/personfinder/pull/161#discussion_r39357217"},"pull_request":{"href":"https://api.github.com/repos/google/personfinder/pulls/161"}}},"pull_request":{"url":"https://api.github.com/repos/google/personfinder/pulls/161","id":44317811,"html_url":"https://github.com/google/personfinder/pull/161","diff_url":"https://github.com/google/personfinder/pull/161.diff","patch_url":"https://github.com/google/personfinder/pull/161.patch","issue_url":"https://api.github.com/repos/google/personfinder/issues/161","number":161,"state":"open","locked":false,"title":"Added Script Variant#67","user":{"login":"prazuma","id":7258066,"avatar_url":"https://avatars.githubusercontent.com/u/7258066?v=3","gravatar_id":"","url":"https://api.github.com/users/prazuma","html_url":"https://github.com/prazuma","followers_url":"https://api.github.com/users/prazuma/followers","following_url":"https://api.github.com/users/prazuma/following{/other_user}","gists_url":"https://api.github.com/users/prazuma/gists{/gist_id}","starred_url":"https://api.github.com/users/prazuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prazuma/subscriptions","organizations_url":"https://api.github.com/users/prazuma/orgs","repos_url":"https://api.github.com/users/prazuma/repos","events_url":"https://api.github.com/users/prazuma/events{/privacy}","received_events_url":"https://api.github.com/users/prazuma/received_events","type":"User","site_admin":false},"body":"http://personfidersanname.appspot.com/global/home.html","created_at":"2015-09-07T03:40:49Z","updated_at":"2015-09-14T02:19:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"383d8bb1624570cb4a394cefa5f1282491b5856f","assignee":{"login":"skywhale","id":872395,"avatar_url":"https://avatars.githubusercontent.com/u/872395?v=3","gravatar_id":"","url":"https://api.github.com/users/skywhale","html_url":"https://github.com/skywhale","followers_url":"https://api.github.com/users/skywhale/followers","following_url":"https://api.github.com/users/skywhale/following{/other_user}","gists_url":"https://api.github.com/users/skywhale/gists{/gist_id}","starred_url":"https://api.github.com/users/skywhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skywhale/subscriptions","organizations_url":"https://api.github.com/users/skywhale/orgs","repos_url":"https://api.github.com/users/skywhale/repos","events_url":"https://api.github.com/users/skywhale/events{/privacy}","received_events_url":"https://api.github.com/users/skywhale/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/google/personfinder/pulls/161/commits","review_comments_url":"https://api.github.com/repos/google/personfinder/pulls/161/comments","review_comment_url":"https://api.github.com/repos/google/personfinder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/personfinder/issues/161/comments","statuses_url":"https://api.github.com/repos/google/personfinder/statuses/ff0770ea983b2840ec705805fa8d22b8b01a3d09","head":{"label":"google:mikahashimoto-add-script-variant","ref":"mikahashimoto-add-script-variant","sha":"ff0770ea983b2840ec705805fa8d22b8b01a3d09","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":25369506,"name":"personfinder","full_name":"google/personfinder","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/personfinder","description":"Person Finder is a searchable missing person database written in Python and hosted on App Engine.","fork":false,"url":"https://api.github.com/repos/google/personfinder","forks_url":"https://api.github.com/repos/google/personfinder/forks","keys_url":"https://api.github.com/repos/google/personfinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/personfinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/personfinder/teams","hooks_url":"https://api.github.com/repos/google/personfinder/hooks","issue_events_url":"https://api.github.com/repos/google/personfinder/issues/events{/number}","events_url":"https://api.github.com/repos/google/personfinder/events","assignees_url":"https://api.github.com/repos/google/personfinder/assignees{/user}","branches_url":"https://api.github.com/repos/google/personfinder/branches{/branch}","tags_url":"https://api.github.com/repos/google/personfinder/tags","blobs_url":"https://api.github.com/repos/google/personfinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/personfinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/personfinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/personfinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/personfinder/statuses/{sha}","languages_url":"https://api.github.com/repos/google/personfinder/languages","stargazers_url":"https://api.github.com/repos/google/personfinder/stargazers","contributors_url":"https://api.github.com/repos/google/personfinder/contributors","subscribers_url":"https://api.github.com/repos/google/personfinder/subscribers","subscription_url":"https://api.github.com/repos/google/personfinder/subscription","commits_url":"https://api.github.com/repos/google/personfinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/personfinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/personfinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/personfinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/personfinder/contents/{+path}","compare_url":"https://api.github.com/repos/google/personfinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/personfinder/merges","archive_url":"https://api.github.com/repos/google/personfinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/personfinder/downloads","issues_url":"https://api.github.com/repos/google/personfinder/issues{/number}","pulls_url":"https://api.github.com/repos/google/personfinder/pulls{/number}","milestones_url":"https://api.github.com/repos/google/personfinder/milestones{/number}","notifications_url":"https://api.github.com/repos/google/personfinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/personfinder/labels{/name}","releases_url":"https://api.github.com/repos/google/personfinder/releases{/id}","created_at":"2014-10-17T17:36:25Z","updated_at":"2015-09-10T17:00:12Z","pushed_at":"2015-09-14T02:13:32Z","git_url":"git://github.com/google/personfinder.git","ssh_url":"git@github.com:google/personfinder.git","clone_url":"https://github.com/google/personfinder.git","svn_url":"https://github.com/google/personfinder","homepage":"https://google.org/personfinder","size":243643,"stargazers_count":104,"watchers_count":104,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":81,"forks":49,"open_issues":81,"watchers":104,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"462e7557fff705719ba50be9b64258da432f36a1","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":25369506,"name":"personfinder","full_name":"google/personfinder","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/personfinder","description":"Person Finder is a searchable missing person database written in Python and hosted on App Engine.","fork":false,"url":"https://api.github.com/repos/google/personfinder","forks_url":"https://api.github.com/repos/google/personfinder/forks","keys_url":"https://api.github.com/repos/google/personfinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/personfinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/personfinder/teams","hooks_url":"https://api.github.com/repos/google/personfinder/hooks","issue_events_url":"https://api.github.com/repos/google/personfinder/issues/events{/number}","events_url":"https://api.github.com/repos/google/personfinder/events","assignees_url":"https://api.github.com/repos/google/personfinder/assignees{/user}","branches_url":"https://api.github.com/repos/google/personfinder/branches{/branch}","tags_url":"https://api.github.com/repos/google/personfinder/tags","blobs_url":"https://api.github.com/repos/google/personfinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/personfinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/personfinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/personfinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/personfinder/statuses/{sha}","languages_url":"https://api.github.com/repos/google/personfinder/languages","stargazers_url":"https://api.github.com/repos/google/personfinder/stargazers","contributors_url":"https://api.github.com/repos/google/personfinder/contributors","subscribers_url":"https://api.github.com/repos/google/personfinder/subscribers","subscription_url":"https://api.github.com/repos/google/personfinder/subscription","commits_url":"https://api.github.com/repos/google/personfinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/personfinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/personfinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/personfinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/personfinder/contents/{+path}","compare_url":"https://api.github.com/repos/google/personfinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/personfinder/merges","archive_url":"https://api.github.com/repos/google/personfinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/personfinder/downloads","issues_url":"https://api.github.com/repos/google/personfinder/issues{/number}","pulls_url":"https://api.github.com/repos/google/personfinder/pulls{/number}","milestones_url":"https://api.github.com/repos/google/personfinder/milestones{/number}","notifications_url":"https://api.github.com/repos/google/personfinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/personfinder/labels{/name}","releases_url":"https://api.github.com/repos/google/personfinder/releases{/id}","created_at":"2014-10-17T17:36:25Z","updated_at":"2015-09-10T17:00:12Z","pushed_at":"2015-09-14T02:13:32Z","git_url":"git://github.com/google/personfinder.git","ssh_url":"git@github.com:google/personfinder.git","clone_url":"https://github.com/google/personfinder.git","svn_url":"https://github.com/google/personfinder","homepage":"https://google.org/personfinder","size":243643,"stargazers_count":104,"watchers_count":104,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":81,"forks":49,"open_issues":81,"watchers":104,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/personfinder/pulls/161"},"html":{"href":"https://github.com/google/personfinder/pull/161"},"issue":{"href":"https://api.github.com/repos/google/personfinder/issues/161"},"comments":{"href":"https://api.github.com/repos/google/personfinder/issues/161/comments"},"review_comments":{"href":"https://api.github.com/repos/google/personfinder/pulls/161/comments"},"review_comment":{"href":"https://api.github.com/repos/google/personfinder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/personfinder/pulls/161/commits"},"statuses":{"href":"https://api.github.com/repos/google/personfinder/statuses/ff0770ea983b2840ec705805fa8d22b8b01a3d09"}}}}