I’m a NTLK/Python beginner and managed to load my own corpus using CategorizedPlaintextCorpusReader but how do I actually train and use the data for classification of text?
>>> from nltk.corpus.reader import CategorizedPlaintextCorpusReader
>>> reader = CategorizedPlaintextCorpusReader('/ebs/category', r'.*\.txt', cat_pattern=r'(.*)\.txt')
>>> len(reader.categories())
234
Assuming you want a naive Bayes classifier with bag of words features:
The resulting
clf‘sclassifymethod can be used on anyFreqDistof words.(But note: from your
cap_pattern, it seems you have sample and a single category per file in your corpus. Please check whether that’s really what you want.)