NltkNet 2.0.0

dotnet add package NltkNet --version 2.0.0
                    
NuGet\Install-Package NltkNet -Version 2.0.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="NltkNet" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NltkNet" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NltkNet" />
                    
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 NltkNet --version 2.0.0
                    
#r "nuget: NltkNet, 2.0.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 NltkNet@2.0.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=NltkNet&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NltkNet&version=2.0.0
                    
Install as a Cake Tool

NltkNet 2.0

.NET 10 wrappers for modern NLTK using Python.NET, without system Python or IronPython installations.

Reference both NltkNet and the matching platform runtime package: NltkNet.Runtime.osx-arm64 (macOS 14+), NltkNet.Runtime.win-x64 (Windows x64), or NltkNet.Runtime.linux-x64 (Linux x64 with glibc 2.28+). Alpine/musl and other architectures are not included. The Linux runtime excludes the Berkeley DB _dbm backend and uses a custom NumPy build without external BLAS/Fortran libraries. Other dbm/shelve backends remain available; matrix-heavy operations may be slower. The library and matching runtime packages use version 2.0.0.

dotnet add package NltkNet --version 2.0.0
# Choose the runtime matching your deployment platform:
dotnet add package NltkNet.Runtime.osx-arm64 --version 2.0.0
using System;
using System.Linq;
using NltkNet;

Nltk.Init();

// No models or corpora required.
using var tokens = Nltk.Tokenize.WordpunctTokenize(
    "Developers build tools. Developers share tools!");
var stemmer = new Nltk.Stem.PorterStemmer();
using PythonValue ownedStemmer = stemmer.PyObject;
var normalized = tokens.AsNet
    .Where(word => word.All(char.IsLetter))
    .Select(word => stemmer.Stem(word.ToLowerInvariant()))
    .ToList();

var frequencies = new Nltk.Probability.FreqDist(normalized);
using PythonValue ownedFrequencies = frequencies.PyObject;
using var common = frequencies.MostCommon(3);
foreach (var (word, count) in common.AsNet)
    Console.WriteLine($"{word}: {count}");
// develop: 2
// tool: 2
// build: 1

For model-backed entity recognition, after provisioning the datasets:

using var tokens = Nltk.Tokenize.WordTokenize("Barack Obama visited Washington.");
using var tagged = Nltk.PosTag(tokens.AsNet);
using PythonValue entities = Nltk.NeChunk(tagged);
Console.WriteLine(entities);

This requires punkt_tab, averaged_perceptron_tagger_eng, maxent_ne_chunker_tab and words. The repository's numbered examples also demonstrate corpora, classification, probabilities and Python interop.

The runtime contains pinned CPython 3.12.16, NLTK 3.10.4 and NumPy 2.5.4. Initialization discovers the runtime automatically, checks its archive hash, and extracts it to a versioned per-user cache. It never downloads dependencies.

Models/corpora are not included. Provision the datasets needed by your application under <application directory>/nltknet/data/. Missing models raise NLTK errors. Review dataset licenses before redistributing them.

Runtime packages include original component terms and a consolidated license under licenses/, also embedded in the runtime archive. See licenses/PUBLISHING-REVIEW.txt for redistribution obligations; publication does not replace downstream distributors' own license review. Windows includes Microsoft runtime DLLs under their own terms, not MIT. Distributors must comply with those terms; see the included Windows review.

This is a breaking migration from IronPython: use Nltk.Init() without paths; AsPython now contains a GIL-aware PythonValue instead of IronPython types. Dispose owned results when finished. Dynamic operations acquire the GIL. The CPython interpreter is process-global and remains alive for the process lifetime. Do not dispose the shared Nltk.Py scope.

See the repository documentation for preparation scripts, NuGet packaging/verification, supported features, dataset deployment, and migration limitations.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 52 10/29/2026
2.0.0-preview.1 41 10/29/2026
1.0.14 5,723 1/1/2021
1.0.13 1,885 1/16/2019
1.0.12 989 1/13/2019
1.0.11 990 1/2/2019
1.0.10 998 1/2/2019
1.0.9 990 1/1/2019
1.0.8 922 1/1/2019
1.0.7 964 1/1/2019
1.0.5 939 1/1/2019
1.0.4 963 12/29/2018
1.0.3 989 1/1/2019
1.0.2 998 12/29/2018
1.0.1 996 12/29/2018
1.0.0 1,008 12/29/2018