El_1988
El_1988

Reputation: 339

Tokenize not working with any string input

I previously posted about a string I extract from a link, for which I want to apply tokenize, with no luck. So tried a simplified example: my command line is very simple:

a="Any Random text at all , nothing freaking works"
sentences = nltk.sent_tokenize(a)

I consistently get:

TypeError: Can't convert 'list' object to str implicitly

I have tried str.(a), a.split, a=a[0], and checked :

>>> type(a)
<class 'str'>

is there something wrong with my Python? I have checked examples and this apparently should be working. Would really appreciate it if someone could run and see if they get results and if so, what might be wrong with my Python

Added image of error

Upvotes: 0

Views: 167

Answers (1)

InQβ
InQβ

Reputation: 521

It's the problem in nltk package itself. As in the picture, it is not the parameter passed in but literal [''] in nltk/data.py which is considered to be list and converting to string.

Re-install nltk package may help?

show the 69th line of nltk/data.py it should be path = []

Upvotes: 1

Related Questions