def text2int(textnum):

    everything=""
    units = {
        "zero":"0", "one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8",
        "nine":"9"}
    
    lastWordWasNum = False
    
    for word in textnum.split():

        if word not in units:
            everything = everything+" "+word
            lastWordWasNum = False
        else:
            if not lastWordWasNum:
                everything = everything + " "
            everything = everything + units[word]
            lastWordWasNum = True                    

    return everything.lstrip()