The Corpus functions
Now it is time to replace recent hardcoded values for the corpus with real functions, so open the evidence service and add the following modifications to it:
// src/app/evidence/evidence.service.ts //... @Injectable() export class EvidenceService { private corpusSize; private corpus: FirebaseListObservable <any>; private IDFs: FirebaseListObservable <any>; //... constructor(http: Http, af: AngularFire) { this.http = http; this.angularFire = af; this.corpus = af.database.list('Evidence/Corpus/Articles'); this.IDFs = af.database.list('Evidence/Corpus/IDFs'); } corpusBuilder(keywords) { // ToDo: // 1. Fetch links for each keyword // 2. Pass the link to EvidenceService for extracting contents // 3. Save them under corpus key for further caluculation } }
Please notice that we have created two children under the Evidence/Corpus key. Apart from articles, we need to keep all IDF calculations somewhere...