{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

131A_1_train_filter

# 131A_1_train_filter - EE131A Probabilities File...

This preview shows pages 1–2. Sign up to view the full content.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % EE131A: Probabilities % % File: train_filter.m % % Author: Nikolaos Kontorinis % % Date: 12/01/04 % % Description: Computes the spam probabilities of the words contained % in the training files bad_freq.txt and good_freq.txt % ATTENTION: % The two files bad_freq.txt and good_freq.txt should be % in the same directory with the .m files. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all; %Open the two files with the training sets fid_bad = fopen('bad_freq.txt','r'); fid_good = fopen('good_freq.txt','r'); Number_bad_words=370; Number_good_words=276; %Read the bad words and their frequencies for m = 1:Number_bad_words n=1; temp = fscanf(fid_bad,'%1c',1); while(~isletter(temp)&&~isfinite(str2double(temp))) %Won't work temp = fscanf(fid_bad,'%1c',1); %Without this end %--Ian Salman % temp = fscanf(fid_bad,'%1c',1); %Read one char each time. bad(m,n)=temp; while(~isspace(temp)) bad(m,n)=temp; temp = fscanf(fid_bad,'%1c',1); n=n+1; end f_bad(m) = fscanf(fid_bad,'%d \n',1); %Read the frequency. end words = bad; %words will hold all the words appearing in the training

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}