title: Creating a custom categorized corpus in NLTK and Python
body: <p>I'm experiencing a bit of a problem which has to do with regular expressions and <code>CategorizedPlaintextCorpusReader</code> in Python.</p>
  
  <p>I want to create a custom categorized corpus and train a Naive-Bayes classifier on it. My issue is the following: I want to have two categories, "pos" and "neg". The positive files are all in one directory, <code>main_dir/pos/*.txt</code>, and the negative ones are in a separate directory, <code>main_dir/neg/*.txt</code>.</p>
  
  <p>How can I use the <code>CategorizedPlaintextCorpusReader</code> to load and label all the positive files in the pos directory, and do the same for the negative ones?</p>
  
  <p>NB: The setup is absolutely the same as the <code>Movie_reviews</code> corpus (<code>~nltk_data\corpora\movie_reviews</code>).</p>