我使用的是Python的NLTK中的TaggedCorpusReader。我想读一个utf8编码的文件。为此,我想尝试将默认编码“none”(关于文档)改为“utf8”。因此,我需要移交到达编码参数的默认参数。在
__init__(self, root, fileids, sep='/',
word_tokenizer=WhitespaceTokenizer(pattern='\\s+',
gaps=True, discard_empty=T...,
sent_tokenizer=RegexpTokenizer(pattern='\n',
gaps=True, discard_empty=True, f...,
para_block_reader=<function read_blankline_block at 0x132be70>,
encoding=None, tag_mapping_function=None)
这是来自googlecode的定义。在
我现在所做的,是这样称呼构造器的:
^{2}$然后我得到这个错误
Traceback (most recent call last):
File "nlpenhg.py", line 2, in <module>
from BonnerCorpus import *
File "path/code/BonnerCorpus.py", line 27
self.corpus = TaggedCorpusReader('.' , filelist, '/', WhitespaceTokenizer(u'\s+', True, True, 56), RegexpTokenizer('n', True, True, 56), <function read_blankline_block at 0x5b731b8>, 'utf8', None)
我想错误来自于这个<function ...
语句。这就是出错的原因吗?这是什么表情?很难用谷歌搜索<
。在
以下内容:
不是表达式,而是python如何将函数表示为字符串:
^{pr2}$所以,既然你不想使用不同的函数,就不要管它。在
可以使用keywords参数以这种方式实例化
TaggedCorpusReader
:如果要将函数作为参数传递,只需使用标识符:
相关问题 更多 >
编程相关推荐