我正在尝试执行以下kaggle assignmnet.我使用gensim包来使用word2vec.我能够创建模型并将其存储到磁盘.但是当我尝试加载文件时,我收到以下错误.
-HP-dx2280-MT-GR541AV:~$ python prog_w2v.py
Traceback (most recent call last):
File "prog_w2v.py", line 7, in <module>
models = gensim.models.Word2Vec.load_word2vec_format('300features_40minwords_10context.txt', binary=True)
File "/usr/local/lib/python2.7/dist-packages/gensim/models/word2vec.py", line 579, in load_word2vec_format
header = utils.to_unicode(fin.readline())
File "/usr/local/lib/python2.7/dist-packages/gensim/utils.py", line 190, in any2unicode
return unicode(text, encoding, errors=errors)
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte
Run Code Online (Sandbox Code Playgroud)
我发现了类似的问题.但我无法解决问题.我的prog_w2v.py如下.
import gensim
import time
start = time.time()
models = gensim.models.Word2Vec.load_word2vec_format('300features_40minwords_10context.txt', binary=True)
end = time.time()
print …Run Code Online (Sandbox Code Playgroud) 我正在使用一个应用程序,我在service.js服务结束时有以下行.
$rootScope.$broadcast('rootScope:Object')
Run Code Online (Sandbox Code Playgroud)
这里Object是API服务的输出.如果我现在想在我的实际app.js文件中使用此Object,我该如何使用它?上面的行指定了什么以及如何在以后的页面中使用它?
任何帮助表示赞赏.
编辑:
从给定的答案尝试以下:
在服务页面中:
this.getobject=function(){
//http api Function call with result as response.data = resp
$rootScope.$broadcast('rootScope:resp',resp);
}
Run Code Online (Sandbox Code Playgroud)
在子范围页面中:
resp=[];
$rootScope.$on('rootScope:resp',function(resp) {
$scope.resp=resp;
console.log(resp);
});
$scope.$on('rootScope:resp', function(e, params){
console.log(params); // respobject
});
Run Code Online (Sandbox Code Playgroud)
不幸的是,两者都没有在控制台上打印.这个方法有什么问题吗?
javascript angularjs angularjs-directive angularjs-rootscope
gensim ×2
python ×2
angularjs ×1
javascript ×1
kaggle ×1
matplotlib ×1
nlp ×1
treemaps ×1
word2vec ×1