{ "task": { "id": "case_20", "name": "spam_message_detector", "summary": "Detect spam messages based on appearance of spam keywords.", "examples": [ { "input": [ "BOS", "poiVg", "poiVg", "now", "b", "V", "now", "now", "TPSI", "click" ], "output": [ "BOS", "not spam", "not spam", "spam", "not spam", "not spam", "spam", "spam", "not spam", "spam" ] }, { "input": [ "BOS", "spam", "offer", "click", "spam", "oCLrZaW", "J", "poiVg", "poiVg", "offer" ], "output": [ "BOS", "not spam", "spam", "spam", "not spam", "not spam", "not spam", "not spam", "not spam", "spam" ] }, { "input": [ "BOS", "no", "V", "poiVg", "now", "b", "no", "offer", "TPSI", "no" ], "output": [ "BOS", "not spam", "not spam", "not spam", "spam", "not spam", "not spam", "spam", "not spam", "not spam" ] }, { "input": [ "BOS", "spam", "spam", "TPSI", "spam", "no", "V", "oCLrZaW", "TPSI", "b" ], "output": [ "BOS", "not spam", "not spam", "not spam", "not spam", "not spam", "not spam", "not spam", "not spam", "not spam" ] }, { "input": [ "BOS", "b", "LB", "now", "spam", "click", "LB", "spam", "b", "J" ], "output": [ "BOS", "not spam", "not spam", "spam", "not spam", "spam", "not spam", "not spam", "not spam", "not spam" ] } ], "is_categorical": true }, "program": "spam_keywords = {\"free\", \"offer\", \"click\", \"now\"}\nkeyword_count = rasp.Map(lambda x: sum(x == keyword for keyword in spam_keywords), sop)\nis_spam = rasp.Map(lambda x: \"spam\" if x > 0 else \"not spam\", keyword_count)\nreturn is_spam", "components": [ { "id": "L0_MLP", "hook": "blocks.0.mlp.hook_post", "role": { "tag": "MAPPER", "note": "Checks each token for membership in a spam-keyword set and emits a spam/not-spam label for that position." }, "rasp_vars": [ "keyword_count", "is_spam" ], "labels": [ "map_1" ] } ] }