This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Tokenisation, Lemmatising, Stemming, Corpus | |
import nltk | |
nltk.download() | |
#eg1 | |
from nltk.tokenize import sent_tokenize, word_tokenize | |
sentence1 = "Ravi and Raj went for a walk" | |
print(word_tokenize(sentence1)) | |
#eg2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#eg1 | |
import re | |
string = "Lotus is the national flower of my country" | |
pattern = "Lotus" | |
ex1 = re.match(pattern, string) | |
print(ex1) | |
#eg2 | |
pattern2 = "Rose" | |
ex2 = re.match(pattern2, string) |