AhoCorasickCore 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package AhoCorasickCore --version 1.0.1                
NuGet\Install-Package AhoCorasickCore -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AhoCorasickCore" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AhoCorasickCore --version 1.0.1                
#r "nuget: AhoCorasickCore, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AhoCorasickCore as a Cake Addin
#addin nuget:?package=AhoCorasickCore&version=1.0.1

// Install AhoCorasickCore as a Cake Tool
#tool nuget:?package=AhoCorasickCore&version=1.0.1                

AhoCorasick

Install

dotnet add package AhoCorasickCore

Use

This implementation of Aho-Corasick can be used in scenarios where a string needs to be matched against several substrings, and each substring is assigned a certain meaning. For example, one could scan an e-mail against a few words known to be used by spammers and trigger some follow-up actions on each match. Instead of doing that linearly (e.g., by calling Contains on each needle), AhoCorasick and similar algorithms scan efficiently by reusing the already traversed space.

A minimal example:

enum WordCategory
{
    Noun,
    Verb,
    Adjective,
    Adverb
}

Dictionary<string, WordCategory> patterns = new Dictionary<string, WordCategory>
{
    {"he", WordCategory.Noun},
    {"she", WordCategory.Noun},
    {"his", WordCategory.Adjective},
    {"hers", WordCategory.Adjective},
    {"run", WordCategory.Verb},
    {"quickly", WordCategory.Adverb}
};

// cache the instance and reuse it, all public methods are thread-safe
AhoCorasick inst = new AhoCorasick<WordCategory>(patterns);

// use Search() for consuming hits via yield
List<AhoCorasickMatch<WordCategory>> results = inst.SearchAll("he runs")

/* returns: [
  {pattern: "he", value: (Noun), pos: 0},
  {pattern: "run", value: (Verb), pos: 3}
] */
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
1.0.2 215 10/3/2024
1.0.1 214 9/7/2024
1.0.0 86 9/7/2024