Efficient algorithms and hardware for Natural Language Processing