{"action":"created","comment":{"url":"https://api.github.com/repos/ludoge/phonetoque/pulls/comments/172936641","pull_request_review_id":102038730,"id":172936641,"diff_hunk":"@@ -0,0 +1,229 @@\n+import requests\n+import random\n+import json\n+\n+\n+# API_URL = 'http://0.0.0.0:5000'\n+API_URL = 'http://127.0.0.1:5001'\n+\n+\n+# -------------- Fonctions pour calculer les stats sur les syllabes ------------------------- #\n+\n+\n+# Ici, pour un mot donné, on incrémente les statistiques de ses syllabes adjacentes\n+def get_statistics(language,word):\n+    i = 0\n+    length = len(word['syllables_ipa'])\n+    for syllable in word['syllables_ipa']:\n+\n+        # récupération de la syllabe dans la BD ou création d'une nouvelle\n+        syll = requests.get(f'{API_URL}/{language}_syllables/{syllable}').json()['result']\n+        new = False\n+        if type(syll) is str:\n+            new = True\n+            try :\n+                ortho = word['syllables'][i]\n+            except (KeyError,IndexError):\n+                ortho = \"\"\n+            syll = {\n+                'language' : language,\n+                'ipa_syllable' : syllable,\n+                'orthographical_syllable' : ortho,\n+                'preceding_ipa_syllable' : {},\n+                'following_ipa_syllable' : {}\n+            }\n+\n+        # ajout de la syllabe précédente dans les statistiques\n+        if i > 0:\n+            previous = word[i-1]\n+        else:\n+            previous = \" \"\n+        try:\n+            syll['preceding_ipa_syllable'][previous] += 1\n+        except KeyError:\n+            syll['preceding_ipa_syllable'][previous] = 1\n+        except TypeError:\n+            syll['preceding_ipa_syllable'] = {previous : 1}\n+\n+        # ajout de la syllabe suivante dans les statistiques\n+        if i < length - 1:\n+            next = word[i+1]\n+        else:\n+            next = \" \"\n+        try:\n+            syll['following_ipa_syllable'][next] += 1\n+        except KeyError:\n+            syll['following_ipa_syllable'][next] = 1","path":"src/sequence_statistics.py","position":56,"original_position":56,"commit_id":"8198a1dfb0b810a01def75fe49036c9f89bd31b1","original_commit_id":"8198a1dfb0b810a01def75fe49036c9f89bd31b1","user":{"login":"oteboul","id":4041625,"avatar_url":"https://avatars2.githubusercontent.com/u/4041625?v=4","gravatar_id":"","url":"https://api.github.com/users/oteboul","html_url":"https://github.com/oteboul","followers_url":"https://api.github.com/users/oteboul/followers","following_url":"https://api.github.com/users/oteboul/following{/other_user}","gists_url":"https://api.github.com/users/oteboul/gists{/gist_id}","starred_url":"https://api.github.com/users/oteboul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oteboul/subscriptions","organizations_url":"https://api.github.com/users/oteboul/orgs","repos_url":"https://api.github.com/users/oteboul/repos","events_url":"https://api.github.com/users/oteboul/events{/privacy}","received_events_url":"https://api.github.com/users/oteboul/received_events","type":"User","site_admin":false},"body":"maybe you can use a defaultdict instead, in this case a defaultdict of defaultdict: `syll = defaultdict(lambda: defaultdict(int))` this means that if the key is not present, it does not fail but assume the default value of int (0).","created_at":"2018-03-07T18:19:57Z","updated_at":"2018-03-07T18:29:03Z","html_url":"https://github.com/ludoge/phonetoque/pull/27#discussion_r172936641","pull_request_url":"https://api.github.com/repos/ludoge/phonetoque/pulls/27","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ludoge/phonetoque/pulls/comments/172936641"},"html":{"href":"https://github.com/ludoge/phonetoque/pull/27#discussion_r172936641"},"pull_request":{"href":"https://api.github.com/repos/ludoge/phonetoque/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/ludoge/phonetoque/pulls/27","id":173462785,"html_url":"https://github.com/ludoge/phonetoque/pull/27","diff_url":"https://github.com/ludoge/phonetoque/pull/27.diff","patch_url":"https://github.com/ludoge/phonetoque/pull/27.patch","issue_url":"https://api.github.com/repos/ludoge/phonetoque/issues/27","number":27,"state":"open","locked":false,"title":"Valentin 3","user":{"login":"valentinArzel","id":32716862,"avatar_url":"https://avatars2.githubusercontent.com/u/32716862?v=4","gravatar_id":"","url":"https://api.github.com/users/valentinArzel","html_url":"https://github.com/valentinArzel","followers_url":"https://api.github.com/users/valentinArzel/followers","following_url":"https://api.github.com/users/valentinArzel/following{/other_user}","gists_url":"https://api.github.com/users/valentinArzel/gists{/gist_id}","starred_url":"https://api.github.com/users/valentinArzel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valentinArzel/subscriptions","organizations_url":"https://api.github.com/users/valentinArzel/orgs","repos_url":"https://api.github.com/users/valentinArzel/repos","events_url":"https://api.github.com/users/valentinArzel/events{/privacy}","received_events_url":"https://api.github.com/users/valentinArzel/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-07T14:10:42Z","updated_at":"2018-03-07T18:29:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9aca522a2cb7ed3920e0802e7eba554c4ccaec7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ludoge/phonetoque/pulls/27/commits","review_comments_url":"https://api.github.com/repos/ludoge/phonetoque/pulls/27/comments","review_comment_url":"https://api.github.com/repos/ludoge/phonetoque/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ludoge/phonetoque/issues/27/comments","statuses_url":"https://api.github.com/repos/ludoge/phonetoque/statuses/8198a1dfb0b810a01def75fe49036c9f89bd31b1","head":{"label":"ludoge:valentin_3","ref":"valentin_3","sha":"8198a1dfb0b810a01def75fe49036c9f89bd31b1","user":{"login":"ludoge","id":32542884,"avatar_url":"https://avatars2.githubusercontent.com/u/32542884?v=4","gravatar_id":"","url":"https://api.github.com/users/ludoge","html_url":"https://github.com/ludoge","followers_url":"https://api.github.com/users/ludoge/followers","following_url":"https://api.github.com/users/ludoge/following{/other_user}","gists_url":"https://api.github.com/users/ludoge/gists{/gist_id}","starred_url":"https://api.github.com/users/ludoge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ludoge/subscriptions","organizations_url":"https://api.github.com/users/ludoge/orgs","repos_url":"https://api.github.com/users/ludoge/repos","events_url":"https://api.github.com/users/ludoge/events{/privacy}","received_events_url":"https://api.github.com/users/ludoge/received_events","type":"User","site_admin":false},"repo":{"id":106590158,"name":"phonetoque","full_name":"ludoge/phonetoque","owner":{"login":"ludoge","id":32542884,"avatar_url":"https://avatars2.githubusercontent.com/u/32542884?v=4","gravatar_id":"","url":"https://api.github.com/users/ludoge","html_url":"https://github.com/ludoge","followers_url":"https://api.github.com/users/ludoge/followers","following_url":"https://api.github.com/users/ludoge/following{/other_user}","gists_url":"https://api.github.com/users/ludoge/gists{/gist_id}","starred_url":"https://api.github.com/users/ludoge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ludoge/subscriptions","organizations_url":"https://api.github.com/users/ludoge/orgs","repos_url":"https://api.github.com/users/ludoge/repos","events_url":"https://api.github.com/users/ludoge/events{/privacy}","received_events_url":"https://api.github.com/users/ludoge/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ludoge/phonetoque","description":null,"fork":false,"url":"https://api.github.com/repos/ludoge/phonetoque","forks_url":"https://api.github.com/repos/ludoge/phonetoque/forks","keys_url":"https://api.github.com/repos/ludoge/phonetoque/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ludoge/phonetoque/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ludoge/phonetoque/teams","hooks_url":"https://api.github.com/repos/ludoge/phonetoque/hooks","issue_events_url":"https://api.github.com/repos/ludoge/phonetoque/issues/events{/number}","events_url":"https://api.github.com/repos/ludoge/phonetoque/events","assignees_url":"https://api.github.com/repos/ludoge/phonetoque/assignees{/user}","branches_url":"https://api.github.com/repos/ludoge/phonetoque/branches{/branch}","tags_url":"https://api.github.com/repos/ludoge/phonetoque/tags","blobs_url":"https://api.github.com/repos/ludoge/phonetoque/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ludoge/phonetoque/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ludoge/phonetoque/git/refs{/sha}","trees_url":"https://api.github.com/repos/ludoge/phonetoque/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ludoge/phonetoque/statuses/{sha}","languages_url":"https://api.github.com/repos/ludoge/phonetoque/languages","stargazers_url":"https://api.github.com/repos/ludoge/phonetoque/stargazers","contributors_url":"https://api.github.com/repos/ludoge/phonetoque/contributors","subscribers_url":"https://api.github.com/repos/ludoge/phonetoque/subscribers","subscription_url":"https://api.github.com/repos/ludoge/phonetoque/subscription","commits_url":"https://api.github.com/repos/ludoge/phonetoque/commits{/sha}","git_commits_url":"https://api.github.com/repos/ludoge/phonetoque/git/commits{/sha}","comments_url":"https://api.github.com/repos/ludoge/phonetoque/comments{/number}","issue_comment_url":"https://api.github.com/repos/ludoge/phonetoque/issues/comments{/number}","contents_url":"https://api.github.com/repos/ludoge/phonetoque/contents/{+path}","compare_url":"https://api.github.com/repos/ludoge/phonetoque/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ludoge/phonetoque/merges","archive_url":"https://api.github.com/repos/ludoge/phonetoque/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ludoge/phonetoque/downloads","issues_url":"https://api.github.com/repos/ludoge/phonetoque/issues{/number}","pulls_url":"https://api.github.com/repos/ludoge/phonetoque/pulls{/number}","milestones_url":"https://api.github.com/repos/ludoge/phonetoque/milestones{/number}","notifications_url":"https://api.github.com/repos/ludoge/phonetoque/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ludoge/phonetoque/labels{/name}","releases_url":"https://api.github.com/repos/ludoge/phonetoque/releases{/id}","deployments_url":"https://api.github.com/repos/ludoge/phonetoque/deployments","created_at":"2017-10-11T18:00:33Z","updated_at":"2018-01-18T09:02:00Z","pushed_at":"2018-03-07T16:39:28Z","git_url":"git://github.com/ludoge/phonetoque.git","ssh_url":"git@github.com:ludoge/phonetoque.git","clone_url":"https://github.com/ludoge/phonetoque.git","svn_url":"https://github.com/ludoge/phonetoque","homepage":null,"size":5339,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":1,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"ludoge:master","ref":"master","sha":"ff62941ef6055caf5048ce4381924e9c636058a2","user":{"login":"ludoge","id":32542884,"avatar_url":"https://avatars2.githubusercontent.com/u/32542884?v=4","gravatar_id":"","url":"https://api.github.com/users/ludoge","html_url":"https://github.com/ludoge","followers_url":"https://api.github.com/users/ludoge/followers","following_url":"https://api.github.com/users/ludoge/following{/other_user}","gists_url":"https://api.github.com/users/ludoge/gists{/gist_id}","starred_url":"https://api.github.com/users/ludoge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ludoge/subscriptions","organizations_url":"https://api.github.com/users/ludoge/orgs","repos_url":"https://api.github.com/users/ludoge/repos","events_url":"https://api.github.com/users/ludoge/events{/privacy}","received_events_url":"https://api.github.com/users/ludoge/received_events","type":"User","site_admin":false},"repo":{"id":106590158,"name":"phonetoque","full_name":"ludoge/phonetoque","owner":{"login":"ludoge","id":32542884,"avatar_url":"https://avatars2.githubusercontent.com/u/32542884?v=4","gravatar_id":"","url":"https://api.github.com/users/ludoge","html_url":"https://github.com/ludoge","followers_url":"https://api.github.com/users/ludoge/followers","following_url":"https://api.github.com/users/ludoge/following{/other_user}","gists_url":"https://api.github.com/users/ludoge/gists{/gist_id}","starred_url":"https://api.github.com/users/ludoge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ludoge/subscriptions","organizations_url":"https://api.github.com/users/ludoge/orgs","repos_url":"https://api.github.com/users/ludoge/repos","events_url":"https://api.github.com/users/ludoge/events{/privacy}","received_events_url":"https://api.github.com/users/ludoge/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ludoge/phonetoque","description":null,"fork":false,"url":"https://api.github.com/repos/ludoge/phonetoque","forks_url":"https://api.github.com/repos/ludoge/phonetoque/forks","keys_url":"https://api.github.com/repos/ludoge/phonetoque/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ludoge/phonetoque/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ludoge/phonetoque/teams","hooks_url":"https://api.github.com/repos/ludoge/phonetoque/hooks","issue_events_url":"https://api.github.com/repos/ludoge/phonetoque/issues/events{/number}","events_url":"https://api.github.com/repos/ludoge/phonetoque/events","assignees_url":"https://api.github.com/repos/ludoge/phonetoque/assignees{/user}","branches_url":"https://api.github.com/repos/ludoge/phonetoque/branches{/branch}","tags_url":"https://api.github.com/repos/ludoge/phonetoque/tags","blobs_url":"https://api.github.com/repos/ludoge/phonetoque/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ludoge/phonetoque/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ludoge/phonetoque/git/refs{/sha}","trees_url":"https://api.github.com/repos/ludoge/phonetoque/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ludoge/phonetoque/statuses/{sha}","languages_url":"https://api.github.com/repos/ludoge/phonetoque/languages","stargazers_url":"https://api.github.com/repos/ludoge/phonetoque/stargazers","contributors_url":"https://api.github.com/repos/ludoge/phonetoque/contributors","subscribers_url":"https://api.github.com/repos/ludoge/phonetoque/subscribers","subscription_url":"https://api.github.com/repos/ludoge/phonetoque/subscription","commits_url":"https://api.github.com/repos/ludoge/phonetoque/commits{/sha}","git_commits_url":"https://api.github.com/repos/ludoge/phonetoque/git/commits{/sha}","comments_url":"https://api.github.com/repos/ludoge/phonetoque/comments{/number}","issue_comment_url":"https://api.github.com/repos/ludoge/phonetoque/issues/comments{/number}","contents_url":"https://api.github.com/repos/ludoge/phonetoque/contents/{+path}","compare_url":"https://api.github.com/repos/ludoge/phonetoque/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ludoge/phonetoque/merges","archive_url":"https://api.github.com/repos/ludoge/phonetoque/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ludoge/phonetoque/downloads","issues_url":"https://api.github.com/repos/ludoge/phonetoque/issues{/number}","pulls_url":"https://api.github.com/repos/ludoge/phonetoque/pulls{/number}","milestones_url":"https://api.github.com/repos/ludoge/phonetoque/milestones{/number}","notifications_url":"https://api.github.com/repos/ludoge/phonetoque/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ludoge/phonetoque/labels{/name}","releases_url":"https://api.github.com/repos/ludoge/phonetoque/releases{/id}","deployments_url":"https://api.github.com/repos/ludoge/phonetoque/deployments","created_at":"2017-10-11T18:00:33Z","updated_at":"2018-01-18T09:02:00Z","pushed_at":"2018-03-07T16:39:28Z","git_url":"git://github.com/ludoge/phonetoque.git","ssh_url":"git@github.com:ludoge/phonetoque.git","clone_url":"https://github.com/ludoge/phonetoque.git","svn_url":"https://github.com/ludoge/phonetoque","homepage":null,"size":5339,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":1,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ludoge/phonetoque/pulls/27"},"html":{"href":"https://github.com/ludoge/phonetoque/pull/27"},"issue":{"href":"https://api.github.com/repos/ludoge/phonetoque/issues/27"},"comments":{"href":"https://api.github.com/repos/ludoge/phonetoque/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/ludoge/phonetoque/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/ludoge/phonetoque/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ludoge/phonetoque/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/ludoge/phonetoque/statuses/8198a1dfb0b810a01def75fe49036c9f89bd31b1"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"oteboul"}}