Extraction and modernization of the filters in activityspam
npm install activityspam-filterExtraction and modernization of the filters in activityspam + a minimal databank reimplementation






``javascript
import { SpamFilter, SimpleDatabankRedis } from 'activityspam-filter';
// Configured like ioredis, so by default it will connect to localhost:6379
const redisDb = new SimpleDatabankRedis();
const filter = new SpamFilter(redisDb);
await filter.train('spam', foo);
await filter.train('ham', bar);
const { isSpam } = await filter.test(abc);
`
* db – a SimpleDatabank compatible class such as the supplied SimpleDatabankRedis
* category – should be either spam or ham depending on what kind of content to train it withobject
* data – should be an or an array of the data that should be tokenized and trained on
Returns an object with properties:
* cat – the supplied category
* object – a stringified representation of the data that's been supplied
* date – the ISO date this training data was created
* elapsed – the amount of milliseconds the training took
* data – should be an object or an array of the data that should be tokenized and tested
Returns an object with properties:
* probability – a number
* isSpam – a boolean
* bestKeys – a list of the best tokens
* elapsed – the amount of milliseconds the check took
Configured like ioredis and provides a SimpleDatabank compatible implementation of that.
* SimpleDatabank` – the structure of a databank style implementation