Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nreco/ahocorasickdoublearraytrie
Very fast C# implementation of Aho Corasick algorithm based on Double Array Trie.
https://github.com/nreco/ahocorasickdoublearraytrie
aho-corasick aho-corasick-algorithm aho-corasick-automation csharp double-array net-core net-standard substring-search trie
Last synced: 3 months ago
JSON representation
Very fast C# implementation of Aho Corasick algorithm based on Double Array Trie.
- Host: GitHub
- URL: https://github.com/nreco/ahocorasickdoublearraytrie
- Owner: nreco
- License: apache-2.0
- Created: 2017-12-06T06:47:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-12T18:46:39.000Z (over 2 years ago)
- Last Synced: 2024-08-09T16:20:25.289Z (6 months ago)
- Topics: aho-corasick, aho-corasick-algorithm, aho-corasick-automation, csharp, double-array, net-core, net-standard, substring-search, trie
- Language: C#
- Size: 2.97 MB
- Stars: 44
- Watchers: 6
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 Release](https://img.shields.io/nuget/v/NReco.Text.AhoCorasickDoubleArrayTrie.svg)](https://www.nuget.org/packages/NReco.Text.AhoCorasickDoubleArrayTrie/) | ![Tests](https://github.com/nreco/AhoCorasickDoubleArrayTrie/actions/workflows/dotnet-test.yml/badge.svg)
* 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() {
{"are", 1},
{"is", 1},
{"he", 2},
{"she", 2},
{"it", 2},
{"we", 2}
};
var matcher = new AhoCorasickDoubleArrayTrie( 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-2022 Vitaliy Fedorchenko (port to C#, improvements) and contributors