Madu Nishant
Madu Nishant

Reputation: 51

Python Spacy NLP - TypeError: Argument 'string' has incorrect type (expected unicode, got str)

I was getting the following error while i was trying to read a txt file in spacy.

TypeError: Argument 'string' has incorrect type (expected unicode, got str)

Here is the code below

from __future__  import unicode_literals
import spacy
nlp= spacy.load('en')
doc_file = nlp(open("example.txt").read())

Upvotes: 5

Views: 4886

Answers (1)

parvaneh shayegh
parvaneh shayegh

Reputation: 528

you should use nlp= spacy.blank('en') instead of spacy.load('en').

nlp= spacy.blank('en')
doc_file = nlp(open("example.txt").read())

Upvotes: 1

Related Questions