-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (41 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
/**
* Dependencies
*/
var
DocumentReaderPipeline = require('./lib/DocumentReaderPipeline')
, DocumentRepository = require('./lib/DocumentRepository')
, LinkAnalyzerPipeline = require('./lib/LinkAnalyzerPipeline')
, Presenter = require('./lib/Presenter')
, SearchEngine = require('./lib/SearchEngine')
, limdu = require('limdu')
, Q = require('q')
;
var presenter = new Presenter();
var searchEngine = new SearchEngine();
var documentReaderInst = new DocumentReaderPipeline();
var documentRepoInst = new DocumentRepository(__dirname + "/repository.json");
var documentClassifier = new limdu.classifiers.Winnow();
presenter.banner();
var pipeline = Q.Promise(function(resolve, reject) {
presenter
.wait(documentRepoInst.ready.bind(documentRepoInst))()
.then(presenter.wait(function() {
return Q.Promise(function(_resolve, _reject) {
documentClassifier.trainBatch(documentRepoInst.getTrains());
_resolve();
});
}))
.then(function() {
resolve();
});
});
pipeline
.then(presenter.askSearchTerms.bind(presenter))
.then(presenter.show('SEARCHING'))
.then(presenter.wait(searchEngine.search))
.then(presenter.show('ANALYZE-PHASE'))
.then(presenter.startAnalyzeLinksPipeline(LinkAnalyzerPipeline, documentReaderInst, documentRepoInst, documentClassifier))
.then(function(data) {
//console.log(data)
});