【发布时间】:2016-07-17 05:28:50
【问题描述】:
我正在尝试创建一个具有两个类别的 CategorizedPlaintextCorpusReader:neg 和 pos。这些类别在文件名中为“_neg”和“_pos”。例子:
bda_TD_2520_HD_001.pdf_neg.txt
info_Ei650_de.pdf_pos
我的代码:
reader = CategorizedPlaintextCorpusReader('C:/users/s/desktop/corpus/', r'.*\.txt',
cat_pattern=r'.*(pos|neg)\.txt')
我得到错误:
AttributeError: 'NoneType' object has no attribute 'group'
我在这里做错了什么?
编辑
我更改了它,现在不再出现原来的错误。不过,我不确定它是否有效,因为我没有得到任何结果:
len(reader.categories()) # nothing
for cat in reader.categories():
print (cat) # nothing
reader.fileids("neg") # ValueError: Category neg not found
【问题讨论】: