Python NLTK | nltk.TweetTokenizer()
Last Updated :
12 Sep, 2023
With the help of NLTK nltk.TweetTokenizer() method, we are able to convert the stream of words into small tokens so that we can analyse the audio stream with the help of nltk.TweetTokenizer() method.
Syntax : nltk.TweetTokenizer() Return : Return the stream of token
Example #1 : In this example when we pass audio stream in the form of string it will converted to small tokens from a long string with the help of nltk.TweetTokenizer() method.
Python3
from nltk.tokenize import TweetTokenizer
tk = TweetTokenizer()
gfg = "Geeks for Geeks"
geek = tk.tokenize(gfg)
print (geek)
|
Output :
[‘Geeks’, ‘for’, ‘Geeks’]
Example #2 :
Python3
from nltk.tokenize import TweetTokenizer
tk = TweetTokenizer()
gfg = ":-) <> () {} [] :-p"
geek = tk.tokenize(gfg)
print (geek)
|
Output :
[‘:-)’, ”, ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘, ‘]’, ‘:-p’]
Share your thoughts in the comments
Please Login to comment...