基本信息
源码名称:C# 敏感词过滤
源码大小:0.09M
文件格式:.zip
开发语言:C#
更新时间:2020-11-19
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

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

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

过滤敏感词


using System;
using System.IO;

namespace WordsFilter
{
    class Program
    {
        static void Main(string[] args)
        {
            using (new OperationTimer("用时(毫秒):"))
            {
                string keys = IOHelper.Read("words.txt").Replace("\r\n", "|");
                WordSearch ws = new WordSearch(keys);
                string str = IOHelper.Read("content.txt");
                string s= ws.Filter(str);
                Console.WriteLine(s);
            }
            Console.Read();
        }
    }

    public class IOHelper
    {
        private static bool Exists(string fileName)
        {
            if (fileName == null || fileName.Trim() == "")
            {
                return false;
            }

            if (File.Exists(fileName))
            {
                return true;
            }

            return false;
        }

        public static string Read(string fileName)
        {
            if (!Exists(fileName))
            {
                return null;
            }
            //将文件信息读入流中
            using (FileStream fs = new FileStream(fileName, FileMode.Open))
            {
                return new StreamReader(fs).ReadToEnd();
            }
        }
    }
}