Skip to content

Commit a48ed32

Browse files
authored
Create lemmatizing.py
1 parent 40a5096 commit a48ed32

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lemmatizing.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# coding: utf-8
2+
import nltk
3+
from nltk.corpus import stopwords
4+
from nltk.stem import WordNetLemmatizer
5+
6+
stopword = stopwords.words('english')
7+
wordnet_lemmatizer = WordNetLemmatizer()
8+
9+
def lemmatize(text):
10+
"""
11+
take string input and lemmatize the words.
12+
use WordNetLemmatizer to lemmatize the words.
13+
"""
14+
word_tokens = nltk.word_tokenize(text)
15+
lemmatized_word = [wordnet_lemmatizer.lemmatize(word) for word in word_tokens]
16+
return (lemmatized_word)
17+
18+
def main():
19+
text = "the functions of this fan is awesome"
20+
print (remove_punct(text))
21+
22+
if __name__ == '__main__':
23+
main()
24+

0 commit comments

Comments
 (0)