简单前端查询
This commit is contained in:
parent
4692601b5b
commit
088758e67b
26
ml/Search.py
26
ml/Search.py
@ -41,7 +41,7 @@ class Search:
|
|||||||
|
|
||||||
|
|
||||||
#'与'查询:先分词,再合并倒排记录,不考虑权重,返回文档号
|
#'与'查询:先分词,再合并倒排记录,不考虑权重,返回文档号
|
||||||
def QueryPhrase(self,searchPhrase,ishow = True):
|
def QueryPhrase(self,searchPhrase,isshow = True):
|
||||||
words = jieba.cut(searchPhrase.decode('utf-8'),cut_all=False)
|
words = jieba.cut(searchPhrase.decode('utf-8'),cut_all=False)
|
||||||
cut = Cut()
|
cut = Cut()
|
||||||
result = set(range(1,100000))
|
result = set(range(1,100000))
|
||||||
@ -56,16 +56,16 @@ class Search:
|
|||||||
for rec in record:
|
for rec in record:
|
||||||
re.add(int(rec))
|
re.add(int(rec))
|
||||||
result = result & re
|
result = result & re
|
||||||
print result
|
if len(result) == 0:
|
||||||
if ishow:
|
print 'Not Exists Record!'
|
||||||
if len(result) == 0:
|
newslist=list()
|
||||||
print 'Not Exists Record!'
|
for rst in result:
|
||||||
else:
|
line = cut.getRow(int(rst),Global.cutnews_origin_dir,Global.filesize)
|
||||||
for rst in result:
|
data = json.loads(line)
|
||||||
line = cut.getRow(int(rst),Global.cutnews_origin_dir,Global.filesize)
|
if isshow:
|
||||||
data = json.loads(line)
|
print data['title'],'\n',data['time'],'\n',data['content'],'\n'
|
||||||
print data['title'],'\n',data['time'],'\n',data['content'],'\n'
|
newslist.append(data)
|
||||||
return result
|
return newslist
|
||||||
|
|
||||||
#返回热点新闻
|
#返回热点新闻
|
||||||
def QueryHotNews(self):
|
def QueryHotNews(self):
|
||||||
@ -75,6 +75,6 @@ class Search:
|
|||||||
def QueryByTime(self):
|
def QueryByTime(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
search = Search()
|
#search = Search()
|
||||||
|
#search.QueryPhrase(sys.argv[1])
|
||||||
#search.QueryPhrase(sys.argv[1])
|
#search.QueryPhrase(sys.argv[1])
|
||||||
search.QueryPhrase(sys.argv[1])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user