Lexical Analysis using Machine Learning in Python