Last active
January 18, 2023 21:56
-
-
Save SKaplanOfficial/14b1a09e4bd1c29ae08710629504b447 to your computer and use it in GitHub Desktop.
PyXA script to classify email subject lines as junk or other using Latent Semantic Mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyXA # Version 0.2.0 | |
app = PyXA.Application("Mail") | |
dataset = { | |
"junk": app.accounts()[0].mailboxes().by_name("Junk").messages().subject(), | |
"other": app.accounts()[0].mailboxes().by_name("INBOX").messages().subject() | |
} | |
queries = [ | |
"Amazon Web Services Billing Statement Available", | |
"Complete my registration form asap receive your rewards" | |
] | |
lsm = PyXA.XALSM(dataset) | |
for query in queries: | |
category = list(dataset.keys())[lsm.categorize_query(query)[0][0] - 1] | |
print(query, "- category:", category) | |
# Amazon Web Services Billing Statement Available - category: other | |
# Complete my registration form asap receive your rewards - category: junk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment