Esempio n. 1
0
def formatText(text):
    # formats the user input:
    #  - makes it all lowercase
    #  - replaces punctuation and numbers with spaces
    #  - removes multiple spaces
    
    text = text.lower()
    text = text.replace('-', ' ')

    text = toStem([text])
    text.replace("'", " ")
    text = re.findall(r"[\w']+", text)
    text = ' '.join(text)
    text = text.strip()
    
    return text
Esempio n. 2
0
def formatText(text):
    # formats the user input:
    #  - makes it all lowercase
    #  - replaces punctuation and numbers with spaces
    #  - removes multiple spaces
    
    text = text.lower()
    text = text.replace('-', ' ')

    exclude = set(string.punctuation)
    text = ''.join(ch for ch in text if ch not in exclude)

    text = toStem([text])
    text = re.sub( '\s+', ' ', text).strip()

    text = ' '.join(text.split())
    text.strip()
    
    return text