AhoStringSearch 0.0.1-alpha1
build test version
See the version list below for details.
dotnet add package AhoStringSearch --version 0.0.1-alpha1
NuGet\Install-Package AhoStringSearch -Version 0.0.1-alpha1
<PackageReference Include="AhoStringSearch" Version="0.0.1-alpha1" />
paket add AhoStringSearch --version 0.0.1-alpha1
#r "nuget: AhoStringSearch, 0.0.1-alpha1"
// Install AhoStringSearch as a Cake Addin #addin nuget:?package=AhoStringSearch&version=0.0.1-alpha1&prerelease // Install AhoStringSearch as a Cake Tool #tool nuget:?package=AhoStringSearch&version=0.0.1-alpha1&prerelease
Aho Search String [한국어]
Description
This project is a C# implementation of the Aho-Corasick algorithm, a powerful and efficient string search algorithm used to find all occurrences of a set of string patterns within a string. This algorithm is particularly useful in applications that need to match multiple patterns simultaneously, such as spam filters and intrusion detection systems.
The Aho-Corasick algorithm was invented by Alfred V. Aho and Margaret J. Corasick in 1975. It allows efficient multi-pattern matching within text by constructing a finite state machine similar to a dictionary.
API
Checks if the input
string matches any of the string patterns.
var input = "He gave her a cookie, but his dog ate it before she could say thanks.";
var search = new AhoStringSearch();
// Build Trie
var trie = search.CreateTrie();
trie.AddString("him");
trie.AddString("it");
trie.AddString("his");
trie.Build();
var actual = search.Search(input);
Assert.Equal("his", actual);
Performance
Searching for the string 4,783rd zombie
from 4,783 string word rules (negative-words.txt)
Method | Mean | Error | StdDev |
---|---|---|---|
AhoTextSearchAll | 253.4 ns | 3.37 ns | 3.15 ns |
AhoTextSearch | 145.8 ns | 1.03 ns | 0.96 ns |
StringContains | 16,971.0 ns | 114.98 ns | 101.92 ns |
Serialization/Deserialization (Experimental Feature)
Since building the Trie for the Aho-Corasick algorithm can be time-consuming, the Trie can be serialized to a file and reloaded when needed.
// Save trie nodes to a file
var search = new AhoStringSearch();
var trie = search.CreateTrie();
trie.AddString("his");
trie.Build();
using var fs = new FileStream("test.trie", FileMode.Create);
using var bw = new BinaryWriter(fs);
var context = new TrieSerializationContext();
context.Write(trie, bw);
// Load trie nodes from a file
using var fs = new FileStream("test.trie", FileMode.Open);
using var br = new BinaryReader(fs);
var context = new TrieSerializationContext();
var root = context.Load(br);
var search = AhoStringSearch.CreateFrom(root);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.0.2 | 87 | 9/12/2024 | |
0.0.1 | 92 | 9/12/2024 | |
0.0.1-alpha1 | 69 | 9/12/2024 |