simplebayes.category module

class simplebayes.category.BayesCategory(name: str)[source]

Bases: object

Represents a trainable category of content for bayesian classification

get_tally() int[source]

Gets the tally of all types

Returns:

The total number of tokens

Return type:

int

get_token_count(word: str) int[source]

Gets the count associated with a provided token/word

Parameters:

word (str) – the token we’re getting the weight of

Returns:

the weight/count of the token

Return type:

int

train_token(word: str, count: int) None[source]

Trains a particular token (increases the weight/count of it)

Parameters:
  • word (str) – the token we’re going to train

  • count (int) – the number of occurrences in the sample

untrain_token(word: str, count: int) None[source]

Untrains a particular token (decreases the weight/count of it)

Parameters:
  • word (str) – the token we’re going to train

  • count (int) – the number of occurrences in the sample