text = "Are you curious about tokenization? Let's see how it works! We need to analyze a couple of sentences with punctuations to see it in action."# Sentence tokenizationfrom nltk.tokenize import sent_tokenizesent_tokenize_list = sent_tokenize(text)print "\nSentence tokenizer:"print sent_tokenize_list# Create a new word tokenizerfrom nltk.tokenize import word_tokenizeprint "\nWord tokenizer:"print word_tokenize(text)# Create a new punkt word tokenizerfrom nltk.tokenize import PunktWordTokenizerpunkt_word_tokenizer = PunktWordTokenizer()print "\nPunkt word tokenizer:"print punkt_word_tokenizer.tokenize(text)# Create a new WordPunct tokenizerfrom nltk.tokenize import WordPunctTokenizerword_punct_tokenizer = WordPunctTokenizer()print "\nWord punct tokenizer:"print word_punct_tokenizer.tokenize(text)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。