jaraco / jaraco/inflect

inconsistency in handling spaces

Open
#26 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature help wanted
Dominant language
Python
Stars
1.1k
Forks
127
PR merge metrics
No merged PRs in 30d

Description

>>> p.number_to_words('11 11')
'one thousand, one hundred and eleven'
>>> p.ordinal(11)
'11th'
>>> p.ordinal('11 ')
'11 th'
>>> p.ordinal('11  ')
'11  th'
>>> p.ordinal('11 11')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ssara29/others/Abin/src/inflect/inflect.py", line 2797, in ordinal
    n = int(num)
ValueError: invalid literal for int() with base 10: '11 11'

While number_to_words is removing all intervening spaces, ordinal ain't doing the same.
Why the inconsistency? Why isn't number_to_words complaining about the space?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in inflect/inflect.py around the ordinal entry point at line 2797, then compare its handling of spaced numeric strings with number_to_words. Reproduce the examples from the issue and determine the intended consistent behavior; done means the behavior is covered by an appropriate regression test and the two entry points no longer handle spaces inconsistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.