How to split a large sample of text into words in Python

0 votes

Hi Guys,

I have one large sample of text. I want to split this text into words. Can anyone tell me how can I do that?

Jun 26, 2020 in Python by akhtar
• 38,230 points
1,055 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use nltk module to split your text into words. I have attached one example below for your reference.

import nltk
word_data = "It originated from the idea that there are readers who prefer learning new skills from the comforts of their drawing rooms"
nltk_tokens = nltk.word_tokenize(word_data)
print (nltk_tokens)
['It', 'originated', 'from', 'the', 'idea', 'that', 'there', 'are', 'readers', 
'who', 'prefer', 'learning', 'new', 'skills', 'from', 'the',
'comforts', 'of', 'their', 'drawing', 'rooms']

I hope this will help you.

answered Jun 26, 2020 by MD
• 95,440 points

Related Questions In Python

0 votes
0 answers
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
3,238 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2, 2019 in Python by anonymous
5,358 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,060 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,479 views
0 votes
1 answer

How to save one list in a text file in Python?

Hi@akhtar, There is no inbuilt function available to ...READ MORE

answered Jun 25, 2020 in Python by MD
• 95,440 points
3,403 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP