예제 #1
0
def check_float(val):
    val = val.replace("point", ".")
    parts = val.split(".")
    try:
        # convert whole number words to a number
        parts[0] = str(text2num(parts[0]))
        # convert decimal words to a number
        parts[1] = str(text2num(parts[1]))
    except:
        pass
    try:
        # joins whole number and decimal together
        val_float = float(".".join(parts))
        return val_float
    except:
        return False
예제 #2
0
def check_int(val):
    # converts words to numbers
    try:
        val = text2num(val)
    except:
        pass
    # checks if val is an integer
    try:
        int_val = int(val)
        return int_val
    except ValueError:
        return False