diff --git a/ml/Search.py b/ml/Search.py index d53fbc9..378e690 100644 --- a/ml/Search.py +++ b/ml/Search.py @@ -7,6 +7,7 @@ sys.setdefaultencoding('utf-8') from Cut import Cut import tools.Global as Global import jieba +import time class Search: def __init__(self): @@ -59,11 +60,18 @@ class Search: if len(result) == 0: print 'Not Exists Record!' newslist=list() + count = 0 for rst in result: + count+=1 + if count > Global.listsize: + break line = cut.getRow(int(rst),Global.cutnews_origin_dir,Global.filesize) data = json.loads(line) if isshow: print data['title'],'\n',data['time'],'\n',data['content'],'\n' + tm = time.localtime(int(data['time'])) + data['time'] = time.strftime('%Y-%m-%d %H:%M:%S',tm) + data['content'] = data['content'][0:Global.snippetsize] newslist.append(data) return newslist diff --git a/ml/Search.pyc b/ml/Search.pyc index a423a4a..933cfa1 100644 Binary files a/ml/Search.pyc and b/ml/Search.pyc differ diff --git a/tools/Global.py b/tools/Global.py index 4b1a84a..a63bf07 100644 --- a/tools/Global.py +++ b/tools/Global.py @@ -7,3 +7,5 @@ inverse_dir=project_root+"data/inversedata/" cutnews_dir=project_root+"data/cutnews/" cutnews_origin_dir=project_root+"data/orinews" filesize = 100 +snippetsize = 500 +listsize = 15 diff --git a/tools/Global.pyc b/tools/Global.pyc index 0b96661..57bb37d 100644 Binary files a/tools/Global.pyc and b/tools/Global.pyc differ diff --git a/web/main.pyc b/web/main.pyc index 4cfc9b0..5cd0b1f 100644 Binary files a/web/main.pyc and b/web/main.pyc differ diff --git a/web/templates/header.html b/web/templates/header.html index 8a0d569..d6f6326 100644 --- a/web/templates/header.html +++ b/web/templates/header.html @@ -9,9 +9,10 @@ $def with(searchword,newslist) -
+ +
-
+
@@ -20,28 +21,25 @@ $def with(searchword,newslist)
-
+
+



$if len(newslist) > 0: $for news in newslist: -
-
+
- $news['title'],时间:$news['time'] + 时间:$news['time'] $news['title']
- $news['content'][0:100] ... 查看全文>>> -
-
- 原始网页链接:$news['url'] + $news['content'] ... 查看全文>>> +

+ 原始网页链接:$news['url']
-
$else: -
-
+
未检索到相关新闻 @@ -50,7 +48,6 @@ $else:
-