StanzaSharp 0.1.0
See the version list below for details.
dotnet add package StanzaSharp --version 0.1.0
NuGet\Install-Package StanzaSharp -Version 0.1.0
<PackageReference Include="StanzaSharp" Version="0.1.0" />
<PackageVersion Include="StanzaSharp" Version="0.1.0" />
<PackageReference Include="StanzaSharp" />
paket add StanzaSharp --version 0.1.0
#r "nuget: StanzaSharp, 0.1.0"
#:package StanzaSharp@0.1.0
#addin nuget:?package=StanzaSharp&version=0.1.0
#tool nuget:?package=StanzaSharp&version=0.1.0
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
nerto the list for named entities:doc.Entities(text, type, character offsets) and a BIOES tag per token (Token.Ner). - Add
sentimentto the list forsentence.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 | Versions 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. |
-
net10.0
- TorchSharp (>= 0.107.0)
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 |