From 6645ab6bfe1294c89d8a4fbafdf3059b3020ca8a Mon Sep 17 00:00:00 2001 From: Chris Rogers Date: Fri, 1 Feb 2019 18:28:40 -0500 Subject: [PATCH] Add short_scale and ordinal args to helpers. This is in support of issues-1959. --- mycroft/util/lang/parse_en.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mycroft/util/lang/parse_en.py b/mycroft/util/lang/parse_en.py index fad7af039d..09bc800951 100644 --- a/mycroft/util/lang/parse_en.py +++ b/mycroft/util/lang/parse_en.py @@ -175,7 +175,7 @@ def _partition_list(items, split_on): return list(filter(lambda x: len(x) != 0, splits)) -def _extract_fraction(tokens): +def _extract_fraction(tokens, short_scale, ordinals): """ Extract fraction numbers from a string. @@ -202,7 +202,7 @@ def _extract_fraction(tokens): if len(partitions) == 3: text = ' '.join([t.word for t in partitions[0]]) - numbers = extract_numbers_with_text(text) + numbers = extract_numbers_with_text(text, short_scale, ordinals) if len(numbers) > 1: return None, None # ensure first is not a fraction and second is a fraction @@ -214,7 +214,7 @@ def _extract_fraction(tokens): return None, None -def _extract_decimal(tokens): +def _extract_decimal(tokens, short_scale, ordinals): """ Extract decimal numbers from a string. @@ -314,11 +314,11 @@ def _extract_number_with_text_en(tokens, short_scale=True, ordinals=False): """ - fraction, fraction_text = _extract_fraction(tokens) + fraction, fraction_text = _extract_fraction(tokens, short_scale, ordinals) if fraction: return fraction, fraction_text - decimal, decimal_text = _extract_decimal(tokens) + decimal, decimal_text = _extract_decimal(tokens, short_scale, ordinals) if decimal: return decimal, decimal_text @@ -517,7 +517,6 @@ def convert_words_to_numbers(text, short_scale=True, ordinals=False): if numbers_to_replace and token.index == numbers_to_replace[0].end_index: numbers_to_replace.pop(0) - return ' '.join(results)