当前位置: 首页 > news >正文

太原本地网站wordpress elegant

太原本地网站,wordpress elegant,wordpress技术博客主题,北京室内设计公司排行榜Aho-Corasick算法简称AC算法#xff0c;也称为AC自动机(Aho-Corasick)算法#xff0c;1975年产生于贝尔实验室#xff08;The Bell Labs#xff09;#xff0c;是一种用于解决多模式字符串匹配的经典算法之一。 the Bell Lab 本文的运行效果#xff1a; AC算法以模式树…Aho-Corasick算法简称AC算法也称为AC自动机(Aho-Corasick)算法1975年产生于贝尔实验室The Bell Labs是一种用于解决多模式字符串匹配的经典算法之一。 the Bell Lab  本文的运行效果 AC算法以模式树字典树Trie、广度优先策略和KMP模式匹配算法为核心内容。 using System; using System.Collections; using System.Collections.Generic; namespace Legalsoft.Truffer.Algorithm {     /// summary     /// Aho_Corasick 算法     /// /summary     public static partial class PatternSearch     {         private static int MAXS 512;         private static int MAXC 26; private static int[] outt new int[MAXS]; private static int[] f new int[MAXS]; private static int[,] g new int[MAXS, MAXC]; private static int buildMatchingMachine(string[] arr, int k)         {             for (int i 0; i outt.Length; i)             {                 outt[i] 0;             } for (int i 0; i MAXS; i)             {                 for (int j 0; j MAXC; j)                 {                     g[i, j] -1;                 }             } int states 1;             for (int i 0; i k; i)             {                 string word arr[i];                 int currentState 0; for (int j 0; j word.Length; j)                 {                     int ch word[j] - A;                     if (g[currentState, ch] -1)                     {                         g[currentState, ch] states;                     }                     currentState g[currentState, ch];                 } outt[currentState] | (1 i);             } for (int ch 0; ch MAXC; ch)             {                 if (g[0, ch] -1)                 {                     g[0, ch] 0;                 }             } for (int i 0; i MAXC; i)             {                 f[i] 0;             } Queueint q new Queueint();             for (int ch 0; ch MAXC; ch)             {                 if (g[0, ch] ! 0)                 {                     f[g[0, ch]] 0;                     q.Enqueue(g[0, ch]);                 }             } while (q.Count ! 0)             {                 int state q.Peek();                 q.Dequeue(); for (int ch 0; ch MAXC; ch)                 {                     if (g[state, ch] ! -1)                     {                         int failure f[state];                         while (g[failure, ch] -1)                         {                             failure f[failure];                         } failure g[failure, ch];                         f[g[state, ch]] failure; outt[g[state, ch]] | outt[failure]; q.Enqueue(g[state, ch]);                     }                 }             }             return states;         } private static int findNextState(int currentState, char nextInput)         {             int answer currentState;             int ch nextInput - A; while (g[answer, ch] -1)             {                 answer f[answer];             }             return g[answer, ch];         } public static Listint Aho_Corasick_Search(string text, string pattern, int k 1)         {             Listint matchs new Listint(); string[] arr new string[1] { pattern };             buildMatchingMachine(arr, k); int currentState 0; for (int i 0; i text.Length; i)             {                 currentState findNextState(currentState, text[i]); if (outt[currentState] 0)                 {                     continue;                 } for (int j 0; j k; j)                 {                     if ((outt[currentState] (1 j)) 0)                     {                         matchs.Add((i - arr[j].Length 1));                     }                 }             } return matchs;         }     } } POWER BY TRUFFER.CN using System; using System.Collections; using System.Collections.Generic;namespace Legalsoft.Truffer.Algorithm {/// summary/// Aho_Corasick 算法/// /summarypublic static partial class PatternSearch{private static int MAXS 512;private static int MAXC 26;private static int[] outt new int[MAXS];private static int[] f new int[MAXS];private static int[,] g new int[MAXS, MAXC];private static int buildMatchingMachine(string[] arr, int k){for (int i 0; i outt.Length; i){outt[i] 0;}for (int i 0; i MAXS; i){for (int j 0; j MAXC; j){g[i, j] -1;}}int states 1;for (int i 0; i k; i){string word arr[i];int currentState 0;for (int j 0; j word.Length; j){int ch word[j] - A;if (g[currentState, ch] -1){g[currentState, ch] states;}currentState g[currentState, ch];}outt[currentState] | (1 i);}for (int ch 0; ch MAXC; ch){if (g[0, ch] -1){g[0, ch] 0;}}for (int i 0; i MAXC; i){f[i] 0;}Queueint q new Queueint();for (int ch 0; ch MAXC; ch){if (g[0, ch] ! 0){f[g[0, ch]] 0;q.Enqueue(g[0, ch]);}}while (q.Count ! 0){int state q.Peek();q.Dequeue();for (int ch 0; ch MAXC; ch){if (g[state, ch] ! -1){int failure f[state];while (g[failure, ch] -1){failure f[failure];}failure g[failure, ch];f[g[state, ch]] failure;outt[g[state, ch]] | outt[failure];q.Enqueue(g[state, ch]);}}}return states;}private static int findNextState(int currentState, char nextInput){int answer currentState;int ch nextInput - A;while (g[answer, ch] -1){answer f[answer];}return g[answer, ch];}public static Listint Aho_Corasick_Search(string text, string pattern, int k 1){Listint matchs new Listint();string[] arr new string[1] { pattern };buildMatchingMachine(arr, k);int currentState 0;for (int i 0; i text.Length; i){currentState findNextState(currentState, text[i]);if (outt[currentState] 0){continue;}for (int j 0; j k; j){if ((outt[currentState] (1 j)) 0){matchs.Add((i - arr[j].Length 1));}}}return matchs;}} }
http://www.hkea.cn/news/14503497/

相关文章:

  • 网站建设从零开始域名命名网站
  • 自己做网站代理产品漳州手机网站开发
  • 网站建设主题大全视频剪辑教程自学
  • 做网站选什么专业网站首页制作的过程
  • 高校网站建设汇报营销型网站建设用途
  • 图片做网站连接关键词排名查询工具免费
  • 网站开发配置wordpress 仿雷锋
  • 建企业网站一般需要多少钱河南企业网站营销设计
  • 新闻静态网站咋做网站建设什么价格
  • 资金盘做网站wordpress 中文语言
  • 咸阳网站建设费用精品课程网站设计与实现
  • wordpress预解析东莞网站SEO优化推广
  • 城乡建设部网站首页上海seo搜索引擎优化期末及答案
  • 技术教程优化搜索引擎整站招聘网站可做哪些推广方案
  • 江门建设银行网站网站开发掌握哪种语言
  • 杭州优质网站建设银川品牌网站建设公司
  • 网站建设商务代表工作总结教育直播平台网站建设费用
  • 户网站建设整改报告物联网设计论文
  • 企业网站主页素描模板dedecms做的网站网站中的图片总是被同一ip恶意点击
  • 厦门 微网站建设公司哪家好电子商务网站应该如何建设
  • 临沂网站建设咨询邢台在百度上做个网站
  • 云南网络网站推广河北高端网站建设
  • 网站建设实训室wordpress 内存不断上升
  • 禅城区建网站公司wordpress 文章描述代码
  • 阿里云外贸建站wordpress底部菜单插件
  • 医院做网站开发上海网页设计经验培训
  • 网页设计的网站配色方案制作网页的常用软件有哪些
  • 长沙手机网站设计常州市钟楼区建设局网站
  • 网站标题权重吗wordpress 在线联系
  • 网站备案省份深圳市腾讯天游科技有限公司