{"action":"created","comment":{"url":"https://api.github.com/repos/mitsuhiko/babel/pulls/comments/36428272","id":36428272,"diff_hunk":"@@ -0,0 +1,97 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"Testing the spelling of numbers\n+\n+:copyright: (c) 2013 by Szabolcs Blága\n+:license: BSD, see LICENSE in babel for more details.\n+\"\"\"\n+from __future__ import unicode_literals\n+\n+import pytest\n+\n+from babel import numbers\n+from babel import number_spelling as numspell\n+\n+\n+def test_context_framework():\n+    cm = numspell.ContextMaker()\n+    c1 = cm(2222.22222)\n+\n+    for side in c1:\n+        assert isinstance(side, numspell.SideContext)\n+        for group in side:\n+            assert isinstance(group, numspell.GroupContext)\n+            for digit in group:\n+                assert isinstance(digit, numspell.DigitContext)\n+                assert digit.value == 2\n+\n+\n+def test_en_GB_cardinal():\n+    assert numbers.spell_number(0, locale='en_GB') == \"zero\"\n+    assert numbers.spell_number(1, locale='en_GB') == \"one\"\n+    assert numbers.spell_number(2, locale='en_GB') == \"two\"\n+    assert numbers.spell_number(3, locale='en_GB') == \"three\"\n+    assert numbers.spell_number('-0', locale='en_GB') == \"minus zero\"\n+    assert numbers.spell_number(123.25, locale='en_GB') == \"one hundred and twenty-three point twenty-five hundredths\"\n+    assert numbers.spell_number(-12, locale='en_GB') == \"minus twelve\"\n+    assert numbers.spell_number(23457829, locale='en_GB') == \"twenty-three million four hundred and fifty-seven thousand eight hundred and twenty-nine\"\n+    assert numbers.spell_number(1950, locale='en_GB') == \"one thousand nine hundred and fifty\"\n+    assert numbers.spell_number(2001, locale='en_GB') == \"two thousand one\"\n+    assert numbers.spell_number('1999.238', locale='en_GB') == \"one thousand nine hundred and ninety-nine point two hundred and thirty-eight thousandths\"\n+    assert numbers.spell_number(-.199923862, locale='en_GB') == \"rounded to minus zero point two tenths\"\n+    assert numbers.spell_number(-.1, locale='en_GB') == \"minus zero point one tenth\" # float to string conversion preserves precision\n+\n+def test_en_GB_ordinal():\n+    assert numbers.spell_number(0, True, locale='en_GB') == \"zeroth\"\n+    assert numbers.spell_number(1, True, locale='en_GB') == \"first\"\n+    assert numbers.spell_number(2, True, locale='en_GB') == \"second\"\n+    assert numbers.spell_number(3, True, locale='en_GB') == \"third\"\n+    assert numbers.spell_number(4, True, locale='en_GB') == \"fourth\"\n+    assert numbers.spell_number(5, True, locale='en_GB') == \"fifth\"\n+    assert numbers.spell_number(6, True, locale='en_GB') == \"sixth\"\n+    assert numbers.spell_number(7, True, locale='en_GB') == \"seventh\"\n+    assert numbers.spell_number(8, True, locale='en_GB') == \"eighth\"\n+    assert numbers.spell_number(9, True, locale='en_GB') == \"ninth\"\n+    assert numbers.spell_number(10, True, locale='en_GB') == \"tenth\"\n+    assert numbers.spell_number(11, True, locale='en_GB') == \"eleventh\"\n+    assert numbers.spell_number(12, True, locale='en_GB') == \"twelfth\"\n+    assert numbers.spell_number(13, True, locale='en_GB') == \"thirteenth\"\n+    assert numbers.spell_number(20, True, locale='en_GB') == \"twentieth\"\n+    assert numbers.spell_number(30, True, locale='en_GB') == \"thirtieth\"\n+    assert numbers.spell_number(40, True, locale='en_GB') == \"fourtieth\"\n+    assert numbers.spell_number(123.25, True, locale='en_GB') == \"cannot spell fractional numbers as ordinals :(\"\n+    assert numbers.spell_number(-12, True, locale='en_GB') == \"minus twelfth\"\n+    assert numbers.spell_number(23457829, True, locale='en_GB') == \"twenty-three million four hundred and fifty-seven thousand eight hundred and twenty-ninth\"\n+    assert numbers.spell_number(1950, True, locale='en_GB') == \"one thousand nine hundred and fiftieth\"\n+    assert numbers.spell_number(2001, True, locale='en_GB') == \"two thousand first\"\n+    assert numbers.spell_number('1999.23862', True, locale='en_GB') == \"cannot spell fractional numbers as ordinals :(\"\n+    assert numbers.spell_number(-.199923862, True, locale='en_GB') == \"cannot spell fractional numbers as ordinals :(\"\n+","path":"tests/test_number_spelling.py","position":68,"original_position":68,"commit_id":"538046500b20e76b5bca92b9c3880c915451f55f","original_commit_id":"538046500b20e76b5bca92b9c3880c915451f55f","user":{"login":"erickwilder","id":607262,"avatar_url":"https://avatars.githubusercontent.com/u/607262?v=3","gravatar_id":"","url":"https://api.github.com/users/erickwilder","html_url":"https://github.com/erickwilder","followers_url":"https://api.github.com/users/erickwilder/followers","following_url":"https://api.github.com/users/erickwilder/following{/other_user}","gists_url":"https://api.github.com/users/erickwilder/gists{/gist_id}","starred_url":"https://api.github.com/users/erickwilder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erickwilder/subscriptions","organizations_url":"https://api.github.com/users/erickwilder/orgs","repos_url":"https://api.github.com/users/erickwilder/repos","events_url":"https://api.github.com/users/erickwilder/events{/privacy}","received_events_url":"https://api.github.com/users/erickwilder/received_events","type":"User","site_admin":false},"body":"You can remove this unnecessary line","created_at":"2015-08-06T15:30:44Z","updated_at":"2015-08-06T15:30:44Z","html_url":"https://github.com/mitsuhiko/babel/pull/114#discussion_r36428272","pull_request_url":"https://api.github.com/repos/mitsuhiko/babel/pulls/114","_links":{"self":{"href":"https://api.github.com/repos/mitsuhiko/babel/pulls/comments/36428272"},"html":{"href":"https://github.com/mitsuhiko/babel/pull/114#discussion_r36428272"},"pull_request":{"href":"https://api.github.com/repos/mitsuhiko/babel/pulls/114"}}},"pull_request":{"url":"https://api.github.com/repos/mitsuhiko/babel/pulls/114","id":22614387,"html_url":"https://github.com/mitsuhiko/babel/pull/114","diff_url":"https://github.com/mitsuhiko/babel/pull/114.diff","patch_url":"https://github.com/mitsuhiko/babel/pull/114.patch","issue_url":"https://api.github.com/repos/mitsuhiko/babel/issues/114","number":114,"state":"open","locked":false,"title":"Number Spelling","user":{"login":"blagasz","id":5508472,"avatar_url":"https://avatars.githubusercontent.com/u/5508472?v=3","gravatar_id":"","url":"https://api.github.com/users/blagasz","html_url":"https://github.com/blagasz","followers_url":"https://api.github.com/users/blagasz/followers","following_url":"https://api.github.com/users/blagasz/following{/other_user}","gists_url":"https://api.github.com/users/blagasz/gists{/gist_id}","starred_url":"https://api.github.com/users/blagasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blagasz/subscriptions","organizations_url":"https://api.github.com/users/blagasz/orgs","repos_url":"https://api.github.com/users/blagasz/repos","events_url":"https://api.github.com/users/blagasz/events{/privacy}","received_events_url":"https://api.github.com/users/blagasz/received_events","type":"User","site_admin":false},"body":"Reinstantiated pull request to make it a clear changeset.\r\n\r\nThe new code for spelling almost exclusively resides in `babel/spelling.py`. I made a generic helper structure to be used for any language. I did not want to interfere with the current structure, but it might be more logical to fit it as a sub-module of `babel.numbers`. I also modified `babel/numbers.py` to add support for spelling with the function `spell_number`. \r\n\r\nThe original spelling that was implemented in `babel/spelling.py` is Hungarian. I also made a draft implementation of British English. I made a basic test suit for both languages at `tests/test_spelling.py`.\r\n\r\nThe spelling framework tries to be as generic as possible, but still structured upon my original non-generic implementation of the Hungarian spelling. The Hungarian language in general and the spelling in particular is very complicated, so I hope that the generic helper structure that is suitable for an easy implementation of the Hungarian spelling would be also suitable for all the other languages. Should any modification need arise I am ready to help.","created_at":"2014-10-12T10:50:43Z","updated_at":"2015-08-06T15:30:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64b7e244b80163a51960c2b563b2ee3e4f8f2d8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mitsuhiko/babel/pulls/114/commits","review_comments_url":"https://api.github.com/repos/mitsuhiko/babel/pulls/114/comments","review_comment_url":"https://api.github.com/repos/mitsuhiko/babel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitsuhiko/babel/issues/114/comments","statuses_url":"https://api.github.com/repos/mitsuhiko/babel/statuses/538046500b20e76b5bca92b9c3880c915451f55f","head":{"label":"blagasz:master","ref":"master","sha":"538046500b20e76b5bca92b9c3880c915451f55f","user":{"login":"blagasz","id":5508472,"avatar_url":"https://avatars.githubusercontent.com/u/5508472?v=3","gravatar_id":"","url":"https://api.github.com/users/blagasz","html_url":"https://github.com/blagasz","followers_url":"https://api.github.com/users/blagasz/followers","following_url":"https://api.github.com/users/blagasz/following{/other_user}","gists_url":"https://api.github.com/users/blagasz/gists{/gist_id}","starred_url":"https://api.github.com/users/blagasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blagasz/subscriptions","organizations_url":"https://api.github.com/users/blagasz/orgs","repos_url":"https://api.github.com/users/blagasz/repos","events_url":"https://api.github.com/users/blagasz/events{/privacy}","received_events_url":"https://api.github.com/users/blagasz/received_events","type":"User","site_admin":false},"repo":{"id":25116620,"name":"babel","full_name":"blagasz/babel","owner":{"login":"blagasz","id":5508472,"avatar_url":"https://avatars.githubusercontent.com/u/5508472?v=3","gravatar_id":"","url":"https://api.github.com/users/blagasz","html_url":"https://github.com/blagasz","followers_url":"https://api.github.com/users/blagasz/followers","following_url":"https://api.github.com/users/blagasz/following{/other_user}","gists_url":"https://api.github.com/users/blagasz/gists{/gist_id}","starred_url":"https://api.github.com/users/blagasz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blagasz/subscriptions","organizations_url":"https://api.github.com/users/blagasz/orgs","repos_url":"https://api.github.com/users/blagasz/repos","events_url":"https://api.github.com/users/blagasz/events{/privacy}","received_events_url":"https://api.github.com/users/blagasz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/blagasz/babel","description":"The new official repository for Babel, the Python Internationalization Library","fork":true,"url":"https://api.github.com/repos/blagasz/babel","forks_url":"https://api.github.com/repos/blagasz/babel/forks","keys_url":"https://api.github.com/repos/blagasz/babel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blagasz/babel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blagasz/babel/teams","hooks_url":"https://api.github.com/repos/blagasz/babel/hooks","issue_events_url":"https://api.github.com/repos/blagasz/babel/issues/events{/number}","events_url":"https://api.github.com/repos/blagasz/babel/events","assignees_url":"https://api.github.com/repos/blagasz/babel/assignees{/user}","branches_url":"https://api.github.com/repos/blagasz/babel/branches{/branch}","tags_url":"https://api.github.com/repos/blagasz/babel/tags","blobs_url":"https://api.github.com/repos/blagasz/babel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blagasz/babel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blagasz/babel/git/refs{/sha}","trees_url":"https://api.github.com/repos/blagasz/babel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blagasz/babel/statuses/{sha}","languages_url":"https://api.github.com/repos/blagasz/babel/languages","stargazers_url":"https://api.github.com/repos/blagasz/babel/stargazers","contributors_url":"https://api.github.com/repos/blagasz/babel/contributors","subscribers_url":"https://api.github.com/repos/blagasz/babel/subscribers","subscription_url":"https://api.github.com/repos/blagasz/babel/subscription","commits_url":"https://api.github.com/repos/blagasz/babel/commits{/sha}","git_commits_url":"https://api.github.com/repos/blagasz/babel/git/commits{/sha}","comments_url":"https://api.github.com/repos/blagasz/babel/comments{/number}","issue_comment_url":"https://api.github.com/repos/blagasz/babel/issues/comments{/number}","contents_url":"https://api.github.com/repos/blagasz/babel/contents/{+path}","compare_url":"https://api.github.com/repos/blagasz/babel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blagasz/babel/merges","archive_url":"https://api.github.com/repos/blagasz/babel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blagasz/babel/downloads","issues_url":"https://api.github.com/repos/blagasz/babel/issues{/number}","pulls_url":"https://api.github.com/repos/blagasz/babel/pulls{/number}","milestones_url":"https://api.github.com/repos/blagasz/babel/milestones{/number}","notifications_url":"https://api.github.com/repos/blagasz/babel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blagasz/babel/labels{/name}","releases_url":"https://api.github.com/repos/blagasz/babel/releases{/id}","created_at":"2014-10-12T10:44:21Z","updated_at":"2014-10-12T10:49:37Z","pushed_at":"2015-08-04T22:01:04Z","git_url":"git://github.com/blagasz/babel.git","ssh_url":"git@github.com:blagasz/babel.git","clone_url":"https://github.com/blagasz/babel.git","svn_url":"https://github.com/blagasz/babel","homepage":"http://babel.pocoo.org/","size":2366,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"mitsuhiko:master","ref":"master","sha":"c02e7f6ea6f90f9a945003982b56fd96c7d7a0d7","user":{"login":"mitsuhiko","id":7396,"avatar_url":"https://avatars.githubusercontent.com/u/7396?v=3","gravatar_id":"","url":"https://api.github.com/users/mitsuhiko","html_url":"https://github.com/mitsuhiko","followers_url":"https://api.github.com/users/mitsuhiko/followers","following_url":"https://api.github.com/users/mitsuhiko/following{/other_user}","gists_url":"https://api.github.com/users/mitsuhiko/gists{/gist_id}","starred_url":"https://api.github.com/users/mitsuhiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitsuhiko/subscriptions","organizations_url":"https://api.github.com/users/mitsuhiko/orgs","repos_url":"https://api.github.com/users/mitsuhiko/repos","events_url":"https://api.github.com/users/mitsuhiko/events{/privacy}","received_events_url":"https://api.github.com/users/mitsuhiko/received_events","type":"User","site_admin":false},"repo":{"id":11150301,"name":"babel","full_name":"mitsuhiko/babel","owner":{"login":"mitsuhiko","id":7396,"avatar_url":"https://avatars.githubusercontent.com/u/7396?v=3","gravatar_id":"","url":"https://api.github.com/users/mitsuhiko","html_url":"https://github.com/mitsuhiko","followers_url":"https://api.github.com/users/mitsuhiko/followers","following_url":"https://api.github.com/users/mitsuhiko/following{/other_user}","gists_url":"https://api.github.com/users/mitsuhiko/gists{/gist_id}","starred_url":"https://api.github.com/users/mitsuhiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitsuhiko/subscriptions","organizations_url":"https://api.github.com/users/mitsuhiko/orgs","repos_url":"https://api.github.com/users/mitsuhiko/repos","events_url":"https://api.github.com/users/mitsuhiko/events{/privacy}","received_events_url":"https://api.github.com/users/mitsuhiko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mitsuhiko/babel","description":"The new official repository for Babel, the Python Internationalization Library","fork":false,"url":"https://api.github.com/repos/mitsuhiko/babel","forks_url":"https://api.github.com/repos/mitsuhiko/babel/forks","keys_url":"https://api.github.com/repos/mitsuhiko/babel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitsuhiko/babel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitsuhiko/babel/teams","hooks_url":"https://api.github.com/repos/mitsuhiko/babel/hooks","issue_events_url":"https://api.github.com/repos/mitsuhiko/babel/issues/events{/number}","events_url":"https://api.github.com/repos/mitsuhiko/babel/events","assignees_url":"https://api.github.com/repos/mitsuhiko/babel/assignees{/user}","branches_url":"https://api.github.com/repos/mitsuhiko/babel/branches{/branch}","tags_url":"https://api.github.com/repos/mitsuhiko/babel/tags","blobs_url":"https://api.github.com/repos/mitsuhiko/babel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitsuhiko/babel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitsuhiko/babel/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitsuhiko/babel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitsuhiko/babel/statuses/{sha}","languages_url":"https://api.github.com/repos/mitsuhiko/babel/languages","stargazers_url":"https://api.github.com/repos/mitsuhiko/babel/stargazers","contributors_url":"https://api.github.com/repos/mitsuhiko/babel/contributors","subscribers_url":"https://api.github.com/repos/mitsuhiko/babel/subscribers","subscription_url":"https://api.github.com/repos/mitsuhiko/babel/subscription","commits_url":"https://api.github.com/repos/mitsuhiko/babel/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitsuhiko/babel/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitsuhiko/babel/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitsuhiko/babel/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitsuhiko/babel/contents/{+path}","compare_url":"https://api.github.com/repos/mitsuhiko/babel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitsuhiko/babel/merges","archive_url":"https://api.github.com/repos/mitsuhiko/babel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitsuhiko/babel/downloads","issues_url":"https://api.github.com/repos/mitsuhiko/babel/issues{/number}","pulls_url":"https://api.github.com/repos/mitsuhiko/babel/pulls{/number}","milestones_url":"https://api.github.com/repos/mitsuhiko/babel/milestones{/number}","notifications_url":"https://api.github.com/repos/mitsuhiko/babel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitsuhiko/babel/labels{/name}","releases_url":"https://api.github.com/repos/mitsuhiko/babel/releases{/id}","created_at":"2013-07-03T12:25:10Z","updated_at":"2015-08-05T17:15:51Z","pushed_at":"2015-08-06T12:00:03Z","git_url":"git://github.com/mitsuhiko/babel.git","ssh_url":"git@github.com:mitsuhiko/babel.git","clone_url":"https://github.com/mitsuhiko/babel.git","svn_url":"https://github.com/mitsuhiko/babel","homepage":"http://babel.pocoo.org/","size":3654,"stargazers_count":380,"watchers_count":380,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":119,"mirror_url":null,"open_issues_count":91,"forks":119,"open_issues":91,"watchers":380,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitsuhiko/babel/pulls/114"},"html":{"href":"https://github.com/mitsuhiko/babel/pull/114"},"issue":{"href":"https://api.github.com/repos/mitsuhiko/babel/issues/114"},"comments":{"href":"https://api.github.com/repos/mitsuhiko/babel/issues/114/comments"},"review_comments":{"href":"https://api.github.com/repos/mitsuhiko/babel/pulls/114/comments"},"review_comment":{"href":"https://api.github.com/repos/mitsuhiko/babel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitsuhiko/babel/pulls/114/commits"},"statuses":{"href":"https://api.github.com/repos/mitsuhiko/babel/statuses/538046500b20e76b5bca92b9c3880c915451f55f"}}}}