StanzaSharp 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package StanzaSharp --version 0.1.0
                    
NuGet\Install-Package StanzaSharp -Version 0.1.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="StanzaSharp" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StanzaSharp" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="StanzaSharp" />
                    
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 StanzaSharp --version 0.1.0
                    
#r "nuget: StanzaSharp, 0.1.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 StanzaSharp@0.1.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=StanzaSharp&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=StanzaSharp&version=0.1.0
                    
Install as a Cake Tool

StanzaSharp

Stanza's English NLP pipeline in .NET:

  • tokenization and sentence splitting
  • multi-word token expansion ("don't" → "do" + "n't")
  • part-of-speech tags and morphological features
  • lemmas
  • dependency parsing
  • named entities (OntoNotes types: PERSON, ORG, GPE, DATE, ...)
  • constituency parsing
  • sentence sentiment (negative, neutral, positive)

It runs Stanza's own pretrained models through TorchSharp, with no Python needed. The output is identical to Python Stanza 1.15.0 on its golden test data.

Install

dotnet add package StanzaSharp
dotnet add package TorchSharp-cpu

Add TorchSharp-cpu (or a TorchSharp-cuda-* package for GPU) for the native libtorch. Its version must match the TorchSharp version StanzaSharp depends on.

Download the models

The models (about 600 MB) come from Stanza's Hugging Face repository. Download them once:

await ModelDownloader.DownloadAsync("models/stanza/en");                            // all, ~600 MB
await ModelDownloader.DownloadAsync("models/stanza/en", "tokenize,mwt,pos,lemma");  // only what these need

Each file is checked against its published MD5, and files already present are kept. Pipeline.Load itself never touches the network.

Use

using StanzaSharp;

using var nlp = Pipeline.Load("models/stanza/en");
var doc = nlp.Process("Barack Obama was born in Hawaii. He was elected president in 2008.");

foreach (var sentence in doc.Sentences)
{
    foreach (var word in sentence.Words)
        Console.WriteLine($"{word.Id}\t{word.Text}\t{word.Lemma}\t{word.Upos}\t{word.Feats}\t{word.Head}\t{word.Deprel}");
    Console.WriteLine(sentence.Constituency); // (ROOT (S (NP (NNP Barack) (NNP Obama)) ...))
}
  • Pipeline.Load(dir, new PipelineOptions { Processors = "tokenize,mwt" }) runs only the listed processors; each needs the ones before it. The default is all eight, like Stanza's English default: tokenize,mwt,pos,lemma,constituency,depparse,sentiment,ner.
  • Add ner to the list for named entities: doc.Entities (text, type, character offsets) and a BIOES tag per token (Token.Ner).
  • Add sentiment to the list for sentence.Sentiment: 0 negative, 1 neutral, 2 positive.
  • Conllu.Write(doc) gives CoNLL-U in Stanza's format.

GPU

Reference TorchSharp-cuda-windows (or TorchSharp-cuda-linux) instead of TorchSharp-cpu, then Pipeline.Load(dir, new PipelineOptions { Device = torch.CUDA, DisableTf32 = true }). DisableTf32 gives output identical to the CPU by turning TF32 off process-wide; with TF32 on (libtorch's default), a few near-tie decisions can differ. See the repository's docs/gpu.md for measurements.

License

Apache 2.0, like Stanza, whose code this ports (see NOTICE). Stanza's models are not included. Their licenses vary with the training data.

Source, issues and docs: https://github.com/bisforboman/StanzaSharp

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 (5)

Showing the top 5 NuGet packages that depend on StanzaSharp:

Package Downloads
StanzaSharp.Cpu.Linux

StanzaSharp plus the CPU libtorch for Linux x64 only. Use instead of StanzaSharp + TorchSharp-cpu, which restores libtorch for Linux, Windows and macOS (about 265 MB of downloads); this restores one platform's.

StanzaSharp.Cpu.MacOS

StanzaSharp plus the CPU libtorch for macOS on Apple Silicon (arm64) only. Use instead of StanzaSharp + TorchSharp-cpu, which restores libtorch for Linux, Windows and macOS (about 265 MB of downloads); this restores one platform's. Needs Homebrew's OpenMP: brew install libomp.

StanzaSharp.Cpu.Windows

StanzaSharp plus the CPU libtorch for Windows x64 only. Use instead of StanzaSharp + TorchSharp-cpu, which restores libtorch for Linux, Windows and macOS (about 265 MB of downloads); this restores one platform's.

StanzaSharp.Cpu.WindowsArm64

StanzaSharp plus the CPU libtorch for Windows on Arm64 only. TorchSharp-cpu has no Windows Arm64 libtorch, so on Windows on Arm this is the package to use.

StanzaSharp.Cuda

The TorchSharp (libtorch) backend for StanzaSharp: runs Stanza's English pipeline on an NVIDIA GPU (CudaBackend.Create()) or on libtorch's CPU kernels (CudaBackend.Cpu). Add TorchSharp-cuda-windows or TorchSharp-cuda-linux (TorchSharp-cpu for the CPU) for the native libtorch.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.0 0 10/13/2026
1.4.0 0 10/13/2026
1.3.0 3 10/12/2026
1.2.0 36 10/12/2026
1.1.0 59 10/12/2026
1.0.0 55 10/10/2026
0.6.0 47 10/10/2026
0.5.1 43 10/10/2026
0.5.0 51 10/9/2026
0.4.2 67 10/7/2026
0.4.1 72 10/7/2026
0.4.0 71 10/7/2026
0.3.0 66 10/6/2026
0.2.0 55 10/6/2026
0.1.0 48 10/6/2026
0.1.0-alpha.2 40 10/6/2026
0.1.0-alpha.1 43 10/6/2026