Add natural language compressor using the nltk module
This commit is contained in:
parent
7057b5c0d7
commit
2e5b3ebf5d
|
@ -0,0 +1,10 @@
|
|||
import nltk
|
||||
from nltk.corpus import stopwords
|
||||
from nltk.tokenize import word_tokenize
|
||||
|
||||
nltk.download('stopwords')
|
||||
nltk.download('punkt')
|
||||
long_sentence = "It's such a fine day today, The sun is out, and the sky is blue. Can you tell me what the weather will be like tomorrow?"
|
||||
word_tokens = word_tokenize(long_sentence)
|
||||
short_sent = ' '.join([t for t in word_tokens if t not in stopwords.words('english')])
|
||||
print(short_sent)
|
Loading…
Reference in New Issue