def interpret_size(text) -> Union[int, List[int]]: """Processes the has_size_ span value and returns int or list[int]""" nums = re.findall("[-0-9]+", text) if len(nums) == 1: # handle "3", "three", etc. return word_to_num(nums[0]) elif len(nums) > 1: # handle "3 x 3", "four by five", etc. return [word_to_num(n) for n in nums] else: # handle "big", "really huge", etc. return size_words.size_str_to_int(text)
def test_str_to_int_mod(self): x = size_words.size_str_to_int("really big") self.assert_in_range(x, size_words.RANGES["huge"])
def test_str_to_int(self): x = size_words.size_str_to_int("big") self.assert_in_range(x, size_words.RANGES["large"])
def ssti(s): return size_str_to_int(s, ranges=RANGES)