API¶
-
antispam.score(msg)[source]¶ Score the message based on the built-in model.
Parameters: msg – Message to be scored in string format.
-
antispam.is_spam(msg)[source]¶ Decide whether the message is a spam or not based on the built-in model.
Parameters: msg – Message to be classified in string format.
antispam.Model¶
-
class
antispam.Model(file_path=None, create_new=False)[source]¶ Save & Load the model in/from the file system using Python’s json module.
Constructs a Model object by the indicated
file_path, if the file does not exist, create a new file and contruct a empty model.Parameters: - file_path – (optional) Path for the model file indicated, if
path is not indicated, use the built-in model file provided by
the author, which is located in the
antispampackage folder. - create_new – (option) Boolean. If
True, create an empty model.file_pathwill be used when saving the model. If there is an existing model file on the path, the existing model file will be overwritten.
- file_path – (optional) Path for the model file indicated, if
path is not indicated, use the built-in model file provided by
the author, which is located in the
antispam.Detector¶
-
class
antispam.Detector(path=None, create_new=False)[source]¶ A baysian spam filter
Parameters: path – (optional) Path for the model file, will be passes to Modeland construct aModelobject based onpath.-
train(msg, is_spam)[source]¶ Train the model.
Parameters: - msg – Message in string format.
- is_spam – Boolean. If True, train the message as a spam, if False, train the message as a ham.
-