Ba je V essayé d etrouV qd mm, ms si je ne trouve pa ca sera tant pis.
Sinon voila le code ke j'ai fé pour linstant, il ne gere pa les codes html, mais je rajouteré cette option qd jrriveré a accéder a un msg sur le serveur des fournisseursz d'accès internet.
Voici mon code (ne pas oublier de modifier le nom et le chemin d'accès du fichier a analyser) :
Global email.s, email2.s, email3.s
Global nbr_mot.l, nbr_fil.l, nbr_mot_tab.f, nbr_phrase.l
#MAX_fil.l = 10
Global Filtre.l, pourcentage.f
Filtre = 0
;file_to_open.s = ProgramParameter()
file_to_open.s = "C:\Anti SPAM\texte.txt"
Dim val_fil.l(#MAX_fil)
Dim found.l(#MAX_fil)
Dim found2.l(#MAX_fil)
;'nombre de mots' = nbr par cathé * val de la cathég
Procedure.f nbr_mot_taboo()
nbr.f = 0: tp.f = 0
For i.l = 1 To nbr_fil
tp = found(i)+ ( (found2(i)-found(i)) *1.5)
nbr = nbr + ( val_fil(i) * tp )
Next
ProcedureReturn nbr
EndProcedure
Procedure.l vrai(a.l)
i.l = 0: If a: i = 1: EndIf
ProcedureReturn i
EndProcedure
; autres options de recherches pour déclarer le mail comme spam
Procedure.l other_options()
nbr_p.l = 0: nbr_m.l = 0: nbr_f.l = 0: nbr_h.l = 0: nbr_ph.l = 0
; recherche du signe '%'
For i.l = 1 To Len(email)
If Mid(email,i,1) = "%"
If nbr_p = 0 : nbr_p = 4 : Else : nbr_p = nbr_p + 2: EndIf
EndIf
Next i
; si le spam contient un trop petit nombre de mots
If nbr_mot < 20 : nbr_m = 20 : EndIf
; si les phrases sont trop courtes
If nbr_mot / nbr_phrase < 12: nbr_f = 4: EndIf
If nbr_mot / nbr_phrase < 8: nbr_f = 10: EndIf
If nbr_mot / nbr_phrase < 6: nbr_f = 17: EndIf
If nbr_mot / nbr_phrase < 4: nbr_f = 25: EndIf
; si ya pa bcp de phrases
If nbr_phrase < 8: nbr_ph = 10: EndIf
If nbr_phrase < 5: nbr_ph = 20: EndIf
; recherche de lien vers des sites web
For i.l = 1 To Len(email)-3
If Mid(email,i,4) = "http"
If nbr_h = 0
nbr_h = 4 + vrai(nbr_mot < 20)*10
Else
nbr_h = nbr_h + 2 + vrai(nbr_mot < 20)*6
EndIf
EndIf
Next i
ProcedureReturn nbr_p + nbr_m + nbr_f + nbr_h + nbr_ph
EndProcedure
; Convertion du texte en minuscule et en modifiant les caractères incorrects
Procedure.s convert(a.s)
out.s = " ": tmp.s = "": t.l = 0: cpt.l = 0: nbr_phrase=1: sui.l
; début de la boucle de traitement
For i.l = 1 To Len(a)
tmp = Mid(a,i,1): t = Asc(tmp)
If i < Len(a) :sui = Asc(Mid(a,i+1,1)): Else :suiv = Asc(" "): EndIf
If t > 223
t = t - 32
If t > 191 And t < 199 : tmp = "a": EndIf
If t > 199 And t < 204 : tmp = "e": EndIf
If t = 199 : tmp = "c": EndIf
If t > 203 And t < 208 : tmp = "i": EndIf
If t > 241 And t < 247 : tmp = "o": EndIf
If t > 248 And t < 253 : tmp = "u": EndIf
EndIf
If t < 48 Or (t > 57 And t < 64) Or (t > 90 And t < 97) Or (t > 122 And t <192)
If Right(out,1) = " "
tmp = ""
Else
tmp = " " : If (sui = Asc(" ") Or t=Asc(" ")):cpt = cpt + 1: EndIf
EndIf
EndIf
If (t = 33 Or t = 46 Or t = 59 Or t = 63)And (sui = Asc(" ")) : nbr_phrase = nbr_phrase + 1: EndIf
out = out + tmp
Next i
If Right(out,1) <> " ": out = out + " " : EndIf
nbr_mot = cpt
ProcedureReturn out
EndProcedure
Procedure.s wout_pt(a.s)
out.s = "": tp.l = 0
For i.l = 1 To Len(a)
tp = Asc(Mid(a,i,1))
;si <> ! , . ; ^
If (tp <> 33 And tp <> 44 And tp <> 46 And tp <> 59 And tp <>Asc("^"))
out = out + Chr(tp)
EndIf
Next i
ProcedureReturn out
EndProcedure
; renvoi le nombre de filtre (selon la zone 'data' )
Procedure.l get_filtre_nbr()
Restore Filtre : a.s = "": i.l = 0
While a <> "EOF"
Read a
If Val(a) : l = l + 1 : EndIf
Wend
If l > #MAX_fil : l = #MAX_fil : EndIf
ProcedureReturn l
EndProcedure
; renvoi le nombre d'occurence de a.s présenteent dans 'email2'
Procedure.l recherche(a.s, b.s)
cpt.l = 0
For i.l = 1 To (Len(b) - Len(a))
If a = Mid(b,i,Len(a)) : cpt = cpt + 1: EndIf
Next i
ProcedureReturn cpt
EndProcedure
; chargement des filtres et recherches de ces mots dans le texte
Procedure search_mot_taboo()
Shared filtres, act_fil
Shared nbr_mot, nbr_mot_tab
Restore Filtre
i.l = 0: j.l = 0 : a.s : b.s
;PrintN("Mots trouvees dans les selections :")
For i.l = 1 To nbr_fil
found(i) = 0
Repeat
Read a : b = LCase(a)
If Val(a) = 0
If Left(b,1) = "|"
found(i) = found(i) + recherche(Right(b,Len(b)-1), email2)
found2(i) = found2(i) + recherche(Right(b,Len(b)-1), email3)
Else
found(i) = found(i) + recherche(" " + b + " ", email2)
found2(i) = found2(i) + recherche(" " + b + " ", email3)
EndIf
EndIf
Until Val(a) > 0
val_fil(i) = Val(a)
;PrintN(Str(i) + " " + Str(found(i)) + " " + Str(found2(i)))
Next i
nbr_mot_tab = nbr_mot_taboo()
EndProcedure
; ##################### DEBUT DU PROGRAMME #############################
nbr_fil = get_filtre_nbr()
t.l : t2.s
If (FileSize(file_to_open) > 0)
OpenFile(1,file_to_open)
While (~(Eof(1)))
t2 = ReadString()
If Len(t2) > 2
email = email + t2
t = Asc(Right(email,1))
If (t = 33 Or t = 46 Or t = 59 Or t = 63): email = email + " ": Else : email = email + ". ": EndIf
EndIf
Wend
CloseFile(1)
OpenConsole()
ConsoleTitle("Anti Spams")
email = LCase(email)
email2 = convert(email)
email3 = wout_pt(email)
OpenFile(1,"out.txt")
WriteString(email2)
writestring(Chr(13) + Chr(10))
WriteString(email3)
CloseFile(1)
; recherche des mots filtres dans la variable 'email'
search_mot_taboo()
pourcentage = (nbr_mot_tab * 100 / nbr_mot) + other_options()
If pourcentage > 100 : pourcentage = 100 : EndIf
;affichages
PrintN("Nombre de mots que comporte le mail : " + Str(nbr_mot))
PrintN("Nombre de mots taboo trouves : " + Str(nbr_mot_tab))
PrintN("Pourcentage que ce mail soit un spam : " + Str(pourcentage))
Input(): CloseConsole()
Else
MessageRequester("Erreur", "Erreur lors de l'ouverture du fichier" + Chr(13) + Chr(10) + "Le fichier '" + file_to_open + "' est introuvable.", 0)
EndIf
End
DataSection
Filtre:
;sexe
Data.s "|sex", "|porno", "cul", "cum", "seins", "tits", "viagra", "4"
;finances
Data.s "promotion", "bonnes affaires", "proposons", "|achet", "prix", "discount"
Data.s "|achat", "|en ligne", "produit", "price", "money", "buy", "free"
Data.s "euros", "subsription", "|inscription","2"
;anglais
Data.s "very", "good", "the", "of", "wish", "visit our web site", "new", "1"
; other
Data.s "win", "congratulation", "1"
; fin des données
Data.s "EOF"
EndDataSection
P.S.:
La liste des mots clé n'est que provisoire. Elle va être totalement remodifiée !
Si vous avez des remarques n'hésités pas j'en prendrait compte !!!!
