Coder Social home page Coder Social logo

jmptrader / ahocorasickdoublearraytrie Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nreco/ahocorasickdoublearraytrie

0.0 1.0 0.0 1.5 MB

Very fast C# implementation of Aho Corasick algorithm based on Double Array Trie.

License: Apache License 2.0

C# 100.00%

ahocorasickdoublearraytrie's Introduction

NReco.Text.AhoCorasickDoubleArrayTrie

Very fast C# implementation of Aho Corasick algorithm based on Double Array Trie: efficient text search of many substrings with O(n) complexity.

NuGet Ubuntu 14.04
NuGet Release Travis CI
  • very fast: can be used for efficient substring search of thousands keywords with O(n) complexity.
  • trie represented with double array approach to minimize memory usage
  • automata state can be effectively saved/loaded to binary stream (say, file)
  • supports case-insensitive search

How to use

// note: keywords may be provided as enumeration of KeyValuePair
var keywords = new Dictionary<string,int>() {
  {"are", 1},
  {"is", 1},
  {"he", 2},
  {"she", 2},
  {"it", 2},
  {"we", 2}
};
var matcher = new AhoCorasickDoubleArrayTrie<int>( keywords );
var text = "we are all champions";
matcher.ParseText(text, (hit) => {
	Console.WriteLine("Matched: {0} = {1}", text.Substring(hit.Begin, hit.Length), hit.Value );
});

License

Licensed under the Apache License, Version 2.0 (see LICENSE file).

This C# implementation is a port of hankcs's https://github.com/hankcs/AhoCorasickDoubleArrayTrie (java) that were licensed under the Apache 2.0 License (see http://www.apache.org/licenses/LICENSE-2.0). Copyright 2017-2019 Vitaliy Fedorchenko (port to C#, improvements) and contributors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.