Add natural language compressor using the nltk module

This commit is contained in:
pancake 2024-01-09 20:08:53 +01:00
parent 7057b5c0d7
commit 2e5b3ebf5d
1 changed files with 10 additions and 0 deletions

10
wip/nl.py Normal file
View File

@ -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)