Closed noviluni closed 4 years ago
Hei @arnavkapoor, I think that we could prioritize this as it will help to define a better structure for the parser.py
.
By the way, I think that: parse_number("1")
should return 1
too.
Sure @noviluni I will start working on this, just confirming even multiple numbers in the same string things should return None.
> parse_number("one two")
None
I will create a PR in a while, however not very sure how exactly do we use it within the main parse function for reusability.
even multiple numbers in the same string things should return None.
I think so.
not very sure how exactly do we use it within the main parse function
I think that we could extract part of the logic currently inside the number_builder()
in another function to be reused by parse_number()
. In fact, the logic would be pretty the same except for:
However, I prefer you to code something and discuss it through the PR, as it will be easier for both to see how it can be applied / refactored. :smile:
Hi @noviluni sure I was wondering about the feasibility of the main parse()
function using this parse_number()
. But of course, they both can use the common number_builder()
.
This structure is what I went with for the current PR #9.
Hi @arnavkapoor! As we have merged the PR I think you can close this issue. :muscle:
I think it could be really useful to have a function called
parse_number()
that expects a written number and returns the equivalent number (Python number):It's easy to imagine use cases, and it will be useful to refactor the current code.
With the currently implemented logic, it shouldn't be difficult to create it by using the
number_builder
.We should decide what to do if we pass something else. I think we could return just
None
.Of course, this will be multi-locale and it would be useful to accept a
locales
orlocale
argument: