-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (16 loc) · 697 Bytes
/
test.py
File metadata and controls
25 lines (16 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from nltk.stem import PorterStemmer
from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.stem import WordNetLemmatizer
wordnet_lemmatizer = WordNetLemmatizer()
ps = PorterStemmer()
example_words = ["watch","watches","reality","realities","essence", "essences", "immigration"]
for w in example_words:
print(ps.stem(w))
for w in example_words:
print(wordnet_lemmatizer.lemmatize(w, pos='v'))
new_text = "It is important to by very pythonly while you are pythoning with python. All pythoners have pythoned poorly at least once."
words = word_tokenize(new_text)
for w in words:
print(ps.stem(w))
for w in words:
print(wordnet_lemmatizer.lemmatize(w, pos='v'))