Python NLTK | nltk.TweetTokenizer()

With the help of NLTK nltk.TweetTokenizer() method, we are able to convert the stream of words into small 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.



filter_none

edit
close

play_arrow

link
brightness_4
code

# import TweetTokenizer() method from nltk
from nltk.tokenize import TweetTokenizer
  
# Create a reference variable for Class TweetTokenizer
tk = TweetTokenizer()
  
# Create a string input
gfg = "Geeks for Geeks"
  
# Use tokenize method
geek = tk.tokenize(gfg)
  
print(geek)

chevron_right


Output :

[‘Geeks’, ‘for’, ‘Geeks’]

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# import TweetTokenizer() method from nltk
from nltk.tokenize import TweetTokenizer
  
# Create a reference variable for Class TweetTokenizer
tk = TweetTokenizer()
  
# Create a string input
gfg = ":-) <> () {} [] :-p"
  
# Use tokenize method
geek = tk.tokenize(gfg)
  
print(geek)

chevron_right


Output :

[‘:-)’, ”, ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘, ‘]’, ‘:-p’]



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.