python代码未在Jupyter笔记本上运行
我有一个已经运行的python代码 代码在命令行中运行良好,但是当我尝试从Jupyter notebook运行时,出现以下错误(您可以在下面找到代码) AttributeError回溯(最近一次呼叫上次)python代码未在Jupyter笔记本上运行,python,jupyter-notebook,attributeerror,gensim,Python,Jupyter Notebook,Attributeerror,Gensim,我有一个已经运行的python代码 代码在命令行中运行良好,但是当我尝试从Jupyter notebook运行时,出现以下错误(您可以在下面找到代码) AttributeError回溯(最近一次呼叫上次) in() ---->1 simServer.queryIndex(‘国家国际集团公司表示计划提交注册声明’) 似乎Jupyter无法连接到tmp/my_服务器/的原因是什么。根据此处的文档,该位置是否需要实际为/tmp/my_server/?@Kyrubas该位置可以在您喜欢的任何地方。。但我
in()
---->1 simServer.queryIndex(‘国家国际集团公司表示计划提交注册声明’)
似乎Jupyter无法连接到
tmp/my_服务器/
的原因是什么。根据此处的文档,该位置是否需要实际为/tmp/my_server/
?@Kyrubas该位置可以在您喜欢的任何地方。。但我不认为这就是问题所在。。服务器能够连接并将索引写入提到的位置。。因此,我想问题出在其他地方。您是否可以显示完整的回溯,以便我们可以看到哪个对象上实际缺少哪个属性?似乎Jupyter无法连接到tmp/my\u服务器/
的原因是什么。根据此处的文档,该位置是否需要实际为/tmp/my_server/
?@Kyrubas该位置可以在您喜欢的任何地方。。但我不认为这就是问题所在。。服务器能够连接并将索引写入提到的位置。。所以我想问题出在别的地方,你能不能显示完整的回溯,这样我们就可以看到哪个对象上实际上缺少了哪个属性
<ipython-input-2-81df834abc60> in queryIndex(self, queryText)
58 print "Querying the INDEX"
59 doc = {'tokens': utils.simple_preprocess(queryText)}
---> 60 print(self.service.find_similar(doc, min_score=0.4, max_results=50))
simServer.queryIndex('National Intergroup Inc said it plans to file a registration statement')
#!/usr/bin/env python
import pickle
import os
import re
import glob
import pprint
import json
from gensim import utils
from simserver import SessionServer
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
class SimilarityServer(object):
def __init__(self):
print "Openning sesesion and setting it to true"
self.service = SessionServer('tmp/my_server/')
self.service.open_session()
self.service.set_autosession(True)
def indexDocs(self):
print "Docs indexing and training"
#train and index
print "Training"
self.service.session.train(None,method='lsi',clear_buffer=False)
print "Indexing"
self.service.session.index(None)
def queryIndex(self,queryText):
print "Querying the INDEX"
doc = {'tokens': utils.simple_preprocess(queryText)}
print(self.service.find_similar(doc, min_score=0.4, max_results=50))
simServer = SimilarityServer()
simServer.queryIndex('National Intergroup Inc said it plans to file a registration statement')