Merge branch 'master' of https://github.com/GodofKim/3line
Showing
3 changed files
with
6 additions
and
23 deletions
... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
14 | "jade": "~1.11.0", | 14 | "jade": "~1.11.0", |
15 | "mecab-ya": "^0.1.1", | 15 | "mecab-ya": "^0.1.1", |
16 | "morgan": "~1.7.0", | 16 | "morgan": "~1.7.0", |
17 | - "multiset-jaccard": "^0.1.1", | 17 | + "multiset-jaccard": "^0.1.2", |
18 | "node-readability": "^2.2.0", | 18 | "node-readability": "^2.2.0", |
19 | "serve-favicon": "~2.3.0", | 19 | "serve-favicon": "~2.3.0", |
20 | "textrank-node": "^0.1.9" | 20 | "textrank-node": "^0.1.9" | ... | ... |
... | @@ -24,8 +24,6 @@ router.get('/', function(req, res, next) { | ... | @@ -24,8 +24,6 @@ router.get('/', function(req, res, next) { |
24 | async.each(sentences, function(sentence_2, callback_2) { | 24 | async.each(sentences, function(sentence_2, callback_2) { |
25 | mecab.nouns(sentence, function(err, result) { | 25 | mecab.nouns(sentence, function(err, result) { |
26 | mecab.nouns(sentence_2, function(err, result_2) { | 26 | mecab.nouns(sentence_2, function(err, result_2) { |
27 | - console.log("result : " , result); | ||
28 | - console.log("result2: " , result_2); | ||
29 | var index = jaccard.index(result, result_2); | 27 | var index = jaccard.index(result, result_2); |
30 | sentenceSimilarity.push(index); | 28 | sentenceSimilarity.push(index); |
31 | callback_2(); | 29 | callback_2(); |
... | @@ -39,9 +37,12 @@ router.get('/', function(req, res, next) { | ... | @@ -39,9 +37,12 @@ router.get('/', function(req, res, next) { |
39 | }, | 37 | }, |
40 | // 3rd param is the function to call when everything's done | 38 | // 3rd param is the function to call when everything's done |
41 | function(err){ | 39 | function(err){ |
42 | - // All tasks are done now | 40 | + // 그래프를 얻었으니 텍스트랭크를 돌린다. |
43 | var Rank = ranker.getTextRank(graph).probabilityNodes; | 41 | var Rank = ranker.getTextRank(graph).probabilityNodes; |
42 | + // 가장 영향력이 큰 노드 세 개를 취한다. | ||
44 | var selectedIndex = ranker.getSelectedIndex(Rank, 3); | 43 | var selectedIndex = ranker.getSelectedIndex(Rank, 3); |
44 | + // 문장의 순서대로 정렬하는 게 문맥상 자연스러운 듯. | ||
45 | + selectedIndex.sort(); | ||
45 | var result = ''; | 46 | var result = ''; |
46 | for(var i = 0; i < 3; i++){ | 47 | for(var i = 0; i < 3; i++){ |
47 | for(var j = 0; j < sentences.length; j++){ | 48 | for(var j = 0; j < sentences.length; j++){ |
... | @@ -58,23 +59,5 @@ router.get('/', function(req, res, next) { | ... | @@ -58,23 +59,5 @@ router.get('/', function(req, res, next) { |
58 | 59 | ||
59 | }); | 60 | }); |
60 | 61 | ||
61 | -// 다른 요약기에 비해 얼마나 성능 향상이 있었는지 확인하기 위함. | ||
62 | -router.get('/read', function(req, res, next) { | ||
63 | - read('http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=104&sid2=232&oid=421&aid=0002379859', function(err, article, meta) { | ||
64 | - | ||
65 | - // Title | ||
66 | - console.log(article.title); | ||
67 | - // Main Article | ||
68 | - console.log(article.content); | ||
69 | - | ||
70 | - res.json({ | ||
71 | - title : article.title, | ||
72 | - content : article.content | ||
73 | - }, function(){ | ||
74 | - // Close article to clean up jsdom and prevent leaks | ||
75 | - article.close(); | ||
76 | - }); | ||
77 | -}); | ||
78 | -}); | ||
79 | 62 | ||
80 | module.exports = router; | 63 | module.exports = router; | ... | ... |
-
Please register or login to post a comment