基本信息
源码名称:C# 贝叶斯算法 垃圾邮件检测 示例源码下载
源码大小:0.14M
文件格式:.zip
开发语言:C#
更新时间:2016-08-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace nBayes.Tests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {

            Index spam = Index.CreateMemoryIndex();//垃圾邮件
            Index notspam = Index.CreateMemoryIndex();//非垃圾邮件

            // train the indexes
            spam.Add(Entry.FromString("代开 发票"));
            spam.Add(Entry.FromString("恭喜 大奖"));
            spam.Add(Entry.FromString("幸运 中奖"));
            notspam.Add(Entry.FromString("通知 删除"));
            notspam.Add(Entry.FromString("提醒 冻结 成功"));

            Analyzer analyzer = new Analyzer();
            CategorizationResult result = analyzer.Categorize(
                 Entry.FromString("恭喜 注册 成功 通知"),
                 spam,
                 notspam);

            switch (result)
            {
                case CategorizationResult.First:
                    Console.WriteLine("垃圾邮件");
                    break;
                case CategorizationResult.Undetermined:
                    Console.WriteLine("Undecided");
                    break;
                case CategorizationResult.Second:
                    Console.WriteLine("非垃圾邮件");
                    break;
            }

        }
    }
}