I have an array with different words and phrases. The user will input a spam message and I'm supposed to check whether there are any matches to the words and phrases already in the array. For each match the score will +1 and if the score is more than 5 then the possibility of it being a spam message is Yes.
My score doesn't increase though and I'm not sure why.
string[] spam = new string[] {"-different words and phrases provided by programmer"};
Console.Write("Key in an email message: ");
string email = Console.ReadLine();
int score = 0;
string pattern = "^\\[a-zA-Z]";
Regex expression = new Regex(pattern);
var regexp = new System.Text.RegularExpressions.Regex(pattern);
if (!regexp.IsMatch(email))
{
score += 1;
}
You can use Linq to solve the problem
In this implementation I'm looking for spam words in case insensitive manner (so
And
,and
,AND
will be count as spam words). To take plurals, ings (i.e.word
,wording
) into account you have to use stemmer.