I am a total newbie. I have a custom text document which is a paragraph. I am trying to read it and display using NLTK.

following is my code;

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from nltk.corpus import PlaintextCorpusReader

corpus_root = ''
wordlists = PlaintextCorpusReader(corpus_root, 'evidence.txt')

I am getting an error;

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 19: invalid start byte

please help.

  • $\begingroup$ what is your goal? Just read the file and print its content? Or is there some NLP model you want to train? $\endgroup$
    – Leevo
    Aug 24 '19 at 16:10
  • $\begingroup$ My goal is to read the file and build bag of words...thank you for the comment though I found the answer...I had copied the text from Mac and was working on windows....there was some error regarding utf-8, i rewrote it on windows and errror was gone...thanks though $\endgroup$ Aug 24 '19 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.