Spaces:
Sleeping
Sleeping
Delete simple_nltk_test.py
Browse files- simple_nltk_test.py +0 -32
simple_nltk_test.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
import nltk
|
| 2 |
-
|
| 3 |
-
print("Testing NLTK installation...")
|
| 4 |
-
|
| 5 |
-
# Test tokenization
|
| 6 |
-
try:
|
| 7 |
-
from nltk.tokenize import word_tokenize, sent_tokenize
|
| 8 |
-
text = "This is a test sentence. NLTK should be able to tokenize this."
|
| 9 |
-
print("\nTokenization test:")
|
| 10 |
-
print(f"Word tokens: {word_tokenize(text)}")
|
| 11 |
-
print(f"Sentences: {sent_tokenize(text)}")
|
| 12 |
-
except Exception as e:
|
| 13 |
-
print(f"Tokenization error: {e}")
|
| 14 |
-
|
| 15 |
-
# Test POS tagging
|
| 16 |
-
try:
|
| 17 |
-
from nltk import pos_tag
|
| 18 |
-
tokens = word_tokenize("This is a test")
|
| 19 |
-
print("\nPOS tagging test:")
|
| 20 |
-
print(f"POS tags: {pos_tag(tokens)}")
|
| 21 |
-
except Exception as e:
|
| 22 |
-
print(f"POS tagging error: {e}")
|
| 23 |
-
|
| 24 |
-
# Test stopwords
|
| 25 |
-
try:
|
| 26 |
-
from nltk.corpus import stopwords
|
| 27 |
-
print("\nStopwords test:")
|
| 28 |
-
print(f"English stopwords (first 5): {stopwords.words('english')[:5]}")
|
| 29 |
-
except Exception as e:
|
| 30 |
-
print(f"Stopwords error: {e}")
|
| 31 |
-
|
| 32 |
-
print("\nNLTK test complete.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|