zoukankan      html  css  js  c++  java
  • 【ToolGood.Words】之【StringSearch】字符串搜索——基于BFS算法

    字符串搜索中,BFS算法很巧妙,个人认为BFS算法效率是最高的。

    【StringSearch】就是根据BFS算法并优化。

    使用方法:

    string s = "中国|国人|zg人|fuck|all|as|19|http://|ToolGood";
    
    string test = "我是中国人";
    
    StringSearch ss = new StringSearch(); 
    
    ss.SetKeywords(s.Split('|'));             
    
    var allss = ss.FindAll(test);
    

    【StringSearch】在目前已知的公开的算法中,效率最高。

    TextSearch : 141ms

    TrieFilter : 158ms

    FastFilter : 105ms

    StringSearch : 30ms

    IllegalWordsSearch jump 1 : 770ms

    IllegalWordsSearch jump 2 : 729ms

    ----------------------- Find All -----------------------------------

    TextSearch : 1,488ms

    TrieFilter : 1,333ms

    FastFilter : 301ms

    StringSearch : 358ms

    IllegalWordsSearch jump 1 : 3,070ms

    IllegalWordsSearch jump 2 : 3,213ms

    注: 在 Find All测试中,FastFilter只能检测出7个,StringSearch检测出14个

    项目地址:

    https://github.com/toolgood/ToolGood.Words

    参考文章:

    http://www.cnblogs.com/yeerh/archive/2011/10/20/2219035.html

    http://www.cnblogs.com/xingd/archive/2008/02/01/1061800.html

  • 相关阅读:
    智能车回忆
    自动化面试问题
    先进控制理论(转载)
    电力电子技术(转载)
    微型计算机原理及应用复习(转载)
    c语言中数值交换用值传递和地址传递
    unity调用苹果端方法
    unity调用安卓arr方法
    unity mono单例
    loading通用界面笔记
  • 原文地址:https://www.cnblogs.com/toolgood/p/6219554.html
Copyright © 2011-2022 走看看