a mini anti spam with lisp

Discussion of Common Lisp
Post Reply
nechalus
Posts: 3
Joined: Tue May 25, 2010 4:09 pm

a mini anti spam with lisp

Post by nechalus » Tue May 25, 2010 4:23 pm

Hello everyone,
I am looking for information that will help me start my project in lisp.
In fact, I must make a mini anti spam lisp that will take as parameter a text file containing an email, then returns if it is spam or not.
I need a very basic algorithm that I have to implement in Lisp.
How can I do?
Thanks.

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: a mini anti spam with lisp

Post by nuntius » Tue May 25, 2010 7:36 pm

Here are some pages that discuss the topic.
http://www.paulgraham.com/antispam.html

For any solution, it helps to collect a bunch of "good" messages and a bunch of "spam" messages to train against.

Here's a simple algorithm.

Count the words that appear in each, and calculate each word's spam-factor as

Code: Select all

g=(number of times this word appears in a good message) / (total word count of all good messages)
b=(number of times this word appears in a bad message) / (total word count of all bad messages)
spam-factor=(g-b)/(g+b)
Then to score a new message, accumulate the spam-factors for each word in the messages (if a word appears 3 times, add the factor 3 times), and then divide by the number of words in the message. Pick a threshold between +1 (pure good) and -1 (pure bad); messages scoring below the threshold are declared to be bad.

That should give you something to work with. May not work terribly well, though.

nechalus
Posts: 3
Joined: Tue May 25, 2010 4:09 pm

Re: a mini anti spam with lisp

Post by nechalus » Wed May 26, 2010 3:31 am

thank you very much.
is an interesting approach, I will try to develop it.
but I have another technical problem with reading files.
In fact, I need to make a function with :
input = the name of a file to read.
output = a list containing the data file.
example :
file.txt = { Hi, i'm sorry i can't come at home tonight.}

input = file.txt
output = ( hi i'm sorry i can't come at home tonight )
there ar any way to do like this ?
Thanks.

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: a mini anti spam with lisp

Post by nuntius » Wed May 26, 2010 10:11 am

(with-snark "No, CL is a dead-end language, designed for AI before files even existed.")

Here's a useful reply.
http://www.gigamonkeys.com/book/files-and-file-io.html

Post Reply