LexiDiff.Snowball 0.4.0

dotnet add package LexiDiff.Snowball --version 0.4.0
                    
NuGet\Install-Package LexiDiff.Snowball -Version 0.4.0
                    
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="LexiDiff.Snowball" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LexiDiff.Snowball" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="LexiDiff.Snowball" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LexiDiff.Snowball --version 0.4.0
                    
#r "nuget: LexiDiff.Snowball, 0.4.0"
                    
#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.
#:package LexiDiff.Snowball@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LexiDiff.Snowball&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=LexiDiff.Snowball&version=0.4.0
                    
Install as a Cake Tool

Build & Tests NuGet

LexiDiff

Token-aware text diffs that favour readability over compactness.

Deletions are shown with strikethrough; additions are shown in bold.

Pure Levenshtein LexiDiff
Alice was beginning to getgetting very tired tof sitting by her sister on the bank, and of havingwith nothing to do. Alice was beginning to getting very tired ofto sitting by her sister on the bank, and of havingwith nothing to do.

LexiDiff compares words and their stems, with optional sentence or paragraph granularity.

  • Language-aware word segmentation with ICU4N and stemming with Snowball
  • Edits aligned to whole words, stems, and suffixes
  • Sentence and paragraph comparison
  • Equal, insert, and delete spans, with unified diff and inline HTML output

Install

Compatibility: Targets .NET Standard 2.0; consumable by .NET Framework 4.8 and .NET 8, 9, and 10.

dotnet add package LexiDiff

Quick Start

using LexiDiff;

LexiDiffResult result = Lexi.Compare(
    "Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do.",
    "Alice was getting very tired to sit by her sister on the bank, with nothing to do.");

Console.WriteLine(result.ToInlineHtml());

LexiDiffResult.Spans contains equal, insert, and delete spans. ApplyTo(original) applies the changes to the original text. ToInlineHtml() HTML-encodes the text and wraps changes in <del> and <ins> tags.

The example highlights these changes:

Alice was beginning to getting very tired ofto sitting by her sister on the bank, and of havingwith nothing to do.

The shared stem in getting stays unchanged. Replacing of with to produces ofto, keeping both words intact.


Granularity Promotion (Sentence / Paragraph)

Use sentence or paragraph granularity to show each changed sentence or paragraph as a whole replacement.

using System.Globalization;
using LexiDiff;

var a = "A sentence. Next entry stays.";
var b = "A new sentence. Next entry stays.";

// Compare whole sentences using English sentence boundaries
var sentenceDiff = Lexi.Compare(
    a, b,
    new LexiOptions {
        PromoteTo = LexGranularity.Sentence,
        SentenceCulture = CultureInfo.GetCultureInfo("en-US")
    });

Console.WriteLine(sentenceDiff.ToUnifiedDiff("a.txt", "b.txt"));

// Paragraph-level promotion
var paraDiff = Lexi.CompareParagraphs(a, b);

Sentence boundaries use ICU4N with the specified culture. Paragraphs split at each newline; a blank line forms a separate paragraph.

Word segmentation and stemming default to English (en-US). To use another language, supply a culture-selection callback through LexiOptions.DetectLang. Set SentenceCulture for sentence boundaries; it defaults to the invariant culture.


Why token-aware?

LexiDiff uses ICU4N to identify words and Snowball to find stems. A word such as cats can split into cat + s, allowing suffix changes to appear independently. Edits preserve these token boundaries.

Original spelling, punctuation, and whitespace are preserved. Use ReconstructA() and ReconstructB() to recover the input texts.


Known Limitations

  • Unified diffs show changes by line. Use ToInlineHtml() for word and suffix highlighting.
  • Snowball’s stemming is heuristic. Words without a usable stem split remain whole.
  • Sentence boundaries around abbreviations (Me., Dr., art.) may require additional tailoring for specialized text.

License

LexiDiff is licensed under Apache-2.0.

Dependency licenses:

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 was computed. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LexiDiff.Snowball:

Package Downloads
LexiDiff

Token-aware diff engine with Snowball stemming, ICU tokenization, and unified diff rendering.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 240 11/12/2026
0.3.1 7,184 1/19/2026
0.3.0 1,214 11/11/2025
0.2.1 281 9/22/2025
0.2.0 279 9/22/2025
0.1.2 285 9/22/2025
0.1.1 309 9/21/2025