solution for remaining tasks of NLP exercise