title: AttributeError: 'str' object has no attribute 'read'
body: <pre><code>list=[]
  ct = 1      
  import numpy as np
  
  import os, os.path
  isfile = os.path.isfile
  join = os.path.join
  fn = 'C:\\Users\\Keshav\\Desktop\\xyz\\data1\\black_and_white\\'
  target = np.array([1, 2, 3, 4, 5])
  num = sum(1 for item in os.listdir(fn) if isfile(join(fn, item)))
  
  
  
  for ct in range(1,num+1):
      f = open(fn+"1_"+str(ct)+".dat","r") 
      list.append(f)
      ct = ct + 1
  
  from sklearn.feature_extraction.text import CountVectorizer
  count_vect = CountVectorizer(input="file")
  X_train_counts = count_vect.fit_transform(list)
  
  from sklearn.feature_extraction.text import TfidfTransformer
  tfidf_transformer = TfidfTransformer()
  X_train_tfidf = tfidf_transformer.fit_transform(X_train_counts)
  #print X_train_tfidf.shape
  
  from sklearn.naive_bayes import MultinomialNB
  clf = MultinomialNB().fit(X_train_tfidf, target)
  #clf.fit(X, y)
  docs_new = ['10 years of marriage and now divorce. I just wasted my entire life too with her.']
  X_new_counts = count_vect.transform(docs_new)
  print X_new_counts
  
  X_new_tfidf = tfidf_transformer.transform(X_new_counts)
  predicted = clf.predict(X_new_tfidf)
  print predicted
  </code></pre>
  
  <p>I am trying to build a multi-class classifier using sklearn using the following <a href="http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html/link" rel="nofollow">link</a>. </p>
  
  <p>The classifier used here is the Multinomial Naive Bayes Classifier. </p>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "C:\Users\Keshav\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile
      execfile(filename, namespace)
    File "C:/Users/Keshav/Desktop/iHeal/mturk-distortions/main1.py", line 40, in &lt;module&gt;
      X_new_counts = count_vect.transform(docs_new)
    File "C:\Users\Keshav\Anaconda\lib\site-packages\sklearn\feature_extraction\text.py", line 867, in transform
      _, X = self._count_vocab(raw_documents, fixed_vocab=True)
    File "C:\Users\Keshav\Anaconda\lib\site-packages\sklearn\feature_extraction\text.py", line 748, in _count_vocab
      for feature in analyze(doc):
    File "C:\Users\Keshav\Anaconda\lib\site-packages\sklearn\feature_extraction\text.py", line 234, in &lt;lambda&gt;
      tokenize(preprocess(self.decode(doc))), stop_words)
    File "C:\Users\Keshav\Anaconda\lib\site-packages\sklearn\feature_extraction\text.py", line 109, in decode
      doc = doc.read()
  AttributeError: 'str' object has no attribute 'read'
  </code></pre>
  
  <p>Any idea how to resolve it? </p>