![]() |
|
#1
|
|||
|
|||
Writing A Basic Spam Filterhi there. i have an small exercise to write a basic spam filter but im stuck on some stuff
Python Code:
the methods i have to complete are listed below. def isSpam(message): def postEmail(message): def handleEmail(message): basically i have to check each line of the email and if html > 60% of the email then it is considerd as SPAM . ive started some of the missing codes but i dont know how to finish them off. any help is apprechiated. thanks alot Last edited by LuciWiz : 03-Dec-2006 at 04:30.
Reason: Please insert your Python code between [py] & [/py] tags
|
|||
|
#2
|
||||
|
||||
Re: Writing A Basic Spam FilterIt looks like you're almost there. You're already doing readlines() for each line in the body. All you have to do is call the function containsTag() while you parse each line and then increment htmlFound. You'll also need to keep track of the number of words in the body so you can divide that total by htmlFound; that will tell you if # of tags is >60%.
Do you need help on the actual parsing of the lines? __________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#3
|
|||
|
|||
Re: Writing A Basic Spam FilterQuote:
that would be great help. im still new to python and im just slightly confused now on what im doing since ive spent a while doing this as ive been using the documentation to do the code so far. thanks for your help |
|
#4
|
||||
|
||||
Re: Writing A Basic Spam FilterHere's an example of searching strings from one of my books:
Python Code:
Here's an example of regular expressions, in case you need to use them: Python Code:
__________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#5
|
|||
|
|||
Re: Writing A Basic Spam Filterokay, thanks.
so i need to use this to complete the def isSpam(message): function? |
|
#6
|
||||
|
||||
Re: Writing A Basic Spam FilterYes. You want to do a readlines() from the file then do a substring search on each line, looking for the HTML tags.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#7
|
|||
|
|||
Re: Writing A Basic Spam Filterhmm, um. im still not sure what im suppose to be doing :S
alll this programming gone to my head |
|
#8
|
||||
|
||||
Re: Writing A Basic Spam FilterIt should go roughly like this:
This isn't the exact way to do it since I'm trying to merge two different code snippets from my book, but it should give you an idea of how to proceed. __________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Median Filter Coding | june_C21 | C Programming Language | 4 | 27-Feb-2006 08:57 |
| [ANN] New script engine: Open Basic (Basic syntax) | MKTMK | Computer Programming Advertisements & Offers | 0 | 01-Sep-2005 06:13 |
| Google attempts to curb blog & guestbook spam | Div | Search Engine Optimization Forum | 7 | 19-Feb-2005 20:11 |
| How do I report spam? | JdS | Open Discussion Forum | 26 | 09-Dec-2003 07:44 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The