Created
November 21, 2020 04:16
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@ github.com/ahmedshahriar | |
This code will remove remove non-English words from text | |
""" | |
import nltk | |
# download nltk english corpus | |
nltk.download('wordnet') | |
wordnet = set(nltk.corpus.wordnet.words()) | |
words = "love ে ী ে া ে ু ্ া োঁ ে" | |
words_cleaned = " ".join(w for w in nltk.wordpunct_tokenize(words) if w.lower() in wordnet ) | |
print(words_cleaned) | |
# output 'love' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment