Open krrishh-org opened 3 years ago
Following function may be added to the class Corpus
to add documents after the Corpus has been instantiated:
// Adds a document to the corpus
addDocument(documentIdentifier, documentString) {
this._documents.set(identifier, new Document(text, this._stopwords));
this._calculateCollectionFrequencies();
this._calculateCollectionFrequencyWeights();
this._calculateDocumentVectors();
}
It will be helpful to add
Corpus.addDocument(identifier, document)
for cases where the documents repository keeps growing over time.