nlp function to pre-process the words