The Wayback Machine - https://web.archive.org/web/20240118183631/https://www.geeksforgeeks.org/python-nltk-nltk-tokenize-stanfordtokenizer/
Open In App
Related Articles

Python NLTK | nltk.tokenize.StanfordTokenizer()

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

With the help of nltk.tokenize.StanfordTokenizer() method, we are able to extract the tokens from string of characters or numbers by using tokenize.StanfordTokenizer() method. It follows stanford standard for generating tokens.

Syntax : tokenize.StanfordTokenizer()
Return : Return the tokens from a string of characters or numbers.

Example #1 :
In this example we can see that by using tokenize.SExprTokenizer() method, we are able to extract the tokens from stream of characters or numbers using stanford standard.




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


Output :

[‘Geeks’, ‘f’, ‘o’, ‘r’, ‘Geeks’]

Example #2 :




# import StanfordTokenizer() method from nltk
from nltk.tokenize.stanford import StanfordTokenizer
     
# Create a reference variable for Class StanfordTokenizer
tk = StanfordTokenizer()
     
# Create a string input
gfg = "This is your great author."
     
# Use tokenize method
geek = tk.tokenize(gfg)
     
print(geek)


Output :

[‘This’, ‘is’, ‘your’, ‘great’, ‘author’, ‘.’]

Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 12 Jun, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials