Skip to content

Commit

Permalink
Merge pull request #4 from AmPhIbIaN26/parse_roman(regex-approach)
Browse files Browse the repository at this point in the history
Parse roman(regex approach)
  • Loading branch information
AmPhIbIaN26 authored May 8, 2021
2 parents 554d553 + 480cf7c commit faecf42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 5 additions & 7 deletions number_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def parse_number(input_string, language=None, numeral_systems=None):
return int(_parse_roman(input_string))

else:
raise ValueError(f'"{numeral_system}" is not a supported numeral system')
raise ValueError(f'{numeral_system!r} is not a supported numeral system')


def parse_fraction(input_string, language=None):
Expand Down Expand Up @@ -335,21 +335,19 @@ def parse(input_string, language=None, numeral_systems=None):
if language is None:
language = _valid_tokens_by_language(input_string)

temporary_sentence = input_string
result = input_string
for numeral_system in numeral_systems:

if numeral_system == 'decimal':
complete_sentence = _parse_decimal(temporary_sentence, language)
temporary_sentence = complete_sentence
result = _parse_decimal(result, language)

elif numeral_system == 'roman':
complete_sentence = _parse_roman(temporary_sentence)
temporary_sentence = complete_sentence
result = _parse_roman(result)

else:
raise ValueError(f'"{numeral_system}" is not a supported numeral system')

return complete_sentence
return result


def _parse_decimal(input_string, language):
Expand Down
3 changes: 0 additions & 3 deletions test.py

This file was deleted.

0 comments on commit faecf42

Please sign in to comment.