• 大小: 124KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-24
  • 语言: C#
  • 标签: C#  敏感  过滤  源码  Filter  

资源简介

C#敏感字过滤源码,里面有两个敏感词过滤字典,源码是winform程序的,下载了就可以进行测试,也可以自己在敏感字字典内加入自己需要过滤的内容。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Foundationhelper
{
    #region 非法关键字过滤 bate 1.1
    /// 
    /// 非法关键词过滤(自动忽略汉字数字字母间的其他字符)
    /// 

    public class FilterWord
    {

        public FilterWord() { }

        public FilterWord(string dictionaryPath)
        {
            this.dictionaryPath = dictionaryPath;
        }

        private string dictionaryPath = string.Empty;
        /// 
        /// 词库路径
        /// 

        public string DictionaryPath
        {
            get { return dictionaryPath; }
            set { dictionaryPath = value; }
        }
        /// 
        /// 内存词典
        /// 

        private WordGroup[] MEMORYLEXICON = new WordGroup[(int)char.MaxValue];

        private string sourctText = string.Empty;
        /// 
        /// 检测源
        /// 

        public string SourctText
        {
            get { return sourctText; }
            set { sourctText = value; }
        }

        /// 
        /// 检测源游标
        /// 

        int cursor = 0;

        /// 
        /// 匹配成功后偏移量
        /// 

        int wordlenght = 0;

        /// 
        /// 检测词游标
        /// 

        int nextCursor = 0;


        private List illegalWords = new List();

        /// 
        /// 检测到的非法词集
        /// 

        public List IllegalWords
        {
            get { return illegalWords; }
        }

        /// 
        /// 判断是否是中文
        /// 

        /// 
        /// 
        private bool isCHS(char character)
        {
            //  中文表意字符的范围 4E00-9FA5
            int charVal = (int)character;
            return (charVal >= 0x4e00 && charVal <= 0x9fa5);
        }

        /// 
        /// 判断是否是数字
        /// 

        /// 
        /// 
        private bool isNum(char character)
        {
            int charVal = (int)character;
            return (charVal >= 48 && charVal <= 57);
        }

        /// 
        /// 判断是否是字母
        /// 

        /// 
        /// 
        private bool isAlphabet(char character)
        {
            int charVal = (int)character;
            return ((charVal >= 97 && charVal <= 122) || (charVal >= 65 && charVal <= 90));
        }


        /// 
        /// 转半角小写的函数(DBC case)
        /// 

        /// 任意字符串
        /// 半角字符串
        ///
        ///全角空格为12288,半角空格为32
        ///其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248
        ///

        private string ToDBC(string input)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-01-15 13:18  BadWord\
     目录           0  2013-09-14 10:05  BadWord\BadWord\
     文件         863  2013-09-07 16:19  BadWord\BadWord.sln
     文件       21504  2013-09-07 17:35  BadWord\BadWord.suo
     文件       46592  2016-01-15 13:14  BadWord\BadWord.v11.suo
     文件        9058  2016-01-15 13:11  BadWord\BadWord\bad.txt
     文件        3827  2013-09-07 16:26  BadWord\BadWord\BadWord.csproj
     目录           0  2013-09-14 10:05  BadWord\BadWord\bin\
     目录           0  2016-01-15 13:13  BadWord\BadWord\bin\Debug\
     文件        9058  2016-01-15 13:11  BadWord\BadWord\bin\Debug\bad.txt
     文件       12288  2016-01-15 13:11  BadWord\BadWord\bin\Debug\BadWord.exe
     文件       32256  2016-01-15 13:11  BadWord\BadWord\bin\Debug\BadWord.pdb
     文件       22984  2016-01-15 13:14  BadWord\BadWord\bin\Debug\BadWord.vshost.exe
     文件         490  2014-01-13 21:31  BadWord\BadWord\bin\Debug\BadWord.vshost.exe.manifest
     文件        9975  2016-01-15 13:04  BadWord\BadWord\Filter.cs
     文件         701  2013-09-07 16:44  BadWord\BadWord\Form1.cs
     文件        2510  2013-09-07 16:25  BadWord\BadWord\Form1.Designer.cs
     文件        5817  2013-09-07 16:25  BadWord\BadWord\Form1.resx
     目录           0  2013-09-14 10:05  BadWord\BadWord\obj\
     目录           0  2013-09-14 10:05  BadWord\BadWord\obj\x86\
     目录           0  2016-01-15 13:11  BadWord\BadWord\obj\x86\Debug\
     文件        1241  2016-01-15 13:14  BadWord\BadWord\obj\x86\Debug\BadWord.csproj.FileListAbsolute.txt
     文件         975  2016-01-15 13:11  BadWord\BadWord\obj\x86\Debug\BadWord.csproj.GenerateResource.Cache
     文件       12288  2016-01-15 13:11  BadWord\BadWord\obj\x86\Debug\BadWord.exe
     文件         180  2016-01-15 13:11  BadWord\BadWord\obj\x86\Debug\BadWord.Form1.resources
     文件       32256  2016-01-15 13:11  BadWord\BadWord\obj\x86\Debug\BadWord.pdb
     文件         180  2016-01-15 13:11  BadWord\BadWord\obj\x86\Debug\BadWord.Properties.Resources.resources
     文件        5420  2016-01-15 13:00  BadWord\BadWord\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7288  2016-01-15 11:54  BadWord\BadWord\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2013-09-07 16:19  BadWord\BadWord\obj\x86\Debug\TempPE\
     文件         488  2013-09-07 16:19  BadWord\BadWord\Program.cs
............此处省略8个文件信息

评论

共有 条评论