Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/naive_bayes.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ function Naivebayes (options) {
this.tokenizer = this.options.tokenizer || defaultTokenizer

//initialize our vocabulary and its size
this.vocabulary = {}
this.vocabulary = Object.create(null);
this.vocabularySize = 0

//number of documents we have learned from
this.totalDocuments = 0

//document frequency table for each of our categories
//=> for each category, how often were documents mapped to it
this.docCount = {}
this.docCount = Object.create(null);

//for each category, how many words total were mapped to it
this.wordCount = {}
this.wordCount = Object.create(null);

//word frequency table for each category
//=> for each category, how frequent was a given word mapped to it
this.wordFrequencyCount = {}
this.wordFrequencyCount = Object.create(null);

//hashmap of our category names
this.categories = {}
this.categories = Object.create(null);
}

/**
Expand All @@ -107,7 +107,7 @@ Naivebayes.prototype.initializeCategory = function (categoryName) {
if (!this.categories[categoryName]) {
this.docCount[categoryName] = 0
this.wordCount[categoryName] = 0
this.wordFrequencyCount[categoryName] = {}
this.wordFrequencyCount[categoryName] = Object.create(null);
this.categories[categoryName] = true
}
return this
Expand Down