所以,我正在尝试学习和理解 Doc2Vec。 我正在关注这个 tutorial .我的输入是一个文档列表,即单词列表列表。这是我的代码的样子:
input = [["word1","word2",..."wordn"],["word1","word2",..."wordn"],...]
documents = TaggedLineDocument(input)
model = doc2vec.Doc2Vec(documents,size = 50, window = 10, min_count = 2, workers=2)
但是我遇到了一些 unicode 错误(尝试用谷歌搜索这个错误,但没有用):
TypeError('don\'t know how to handle uri %s' % repr(uri))
有人可以帮我理解我哪里出错了吗?谢谢 !
请您参考如下方法:
TaggedLineDocument 应使用文件路径进行实例化。确保文件设置为一个文档等于一行的格式。
documents = TaggedLineDocument('myfile.txt')
documents = TaggedLineDocument('compressed_text.txt.gz')
来自source code :
uri(认为您正在实例化 TaggedLineDocument)可以是:
1. a URI for the local filesystem (compressed ``.gz`` or ``.bz2`` files handled automatically):
`./lines.txt`, `/home/joe/lines.txt.gz`, `file:///home/joe/lines.txt.bz2`
2. a URI for HDFS: `hdfs:///some/path/lines.txt`
3. a URI for Amazon's S3 (can also supply credentials inside the URI):
`s3://my_bucket/lines.txt`, `s3://my_aws_key_id:key_secret@my_bucket/lines.txt`
4. an instance of the boto.s3.key.Key class.
