I’ve been self-hosting email with Maddy for a bit, but haven’t shared any of the addresses widely yet in part because I haven’t set up a spam filter. I’m pleased with Maddy; there’s much less to learn to get a server up and running with sane default behavior than with the email software of old.
Ideally, I’d like to go beyond just spam filtering and have something with arbitrary categories like newsletters and password resets. I would prefer that it learn categories when I move messages to IMAP folders from a mail client. Maddy can feed messages into arbitrary programs and pick a destination folder based on their output.
Web searches turn up a ton of classification programs, most of which seem to be more interested in playing accuracy golf with well-known corpora than expanding functionality beyond simple spam filtering.
I’ve been using rspamd for a while. It may be extensible to do token based classification like you want but it may take some work.