def numericalPrefix(dayMatch): # Grab 'three' of 'three weeks from' prefix = input.split(dayMatch.group(1))[0].strip().split(' ') prefix.reverse() prefix = filter(lambda s: s != 'and', prefix) # Generate best guess number service = NumberService() num = prefix[0] if service.isValid(num): for n in prefix[1:]: inc = n + " " + num if service.isValid(inc): num = inc else: break return service.parse(num) return 1
def findConstantMultiplications(input): split = input.split(' ') revision = "" converter = NumberService() for i, w in enumerate(split): if i > 0 and w in MathService.__constants__: if converter.isValid(split[i - 1]): revision += " times" if not revision: revision = w else: revision += " " + w return revision