![]() |
VOOZH | about |
dotnet add package SentimentAnalyzer --version 3.0.0
NuGet\Install-Package SentimentAnalyzer -Version 3.0.0
<PackageReference Include="SentimentAnalyzer" Version="3.0.0" />
<PackageVersion Include="SentimentAnalyzer" Version="3.0.0" />Directory.Packages.props
<PackageReference Include="SentimentAnalyzer" />Project file
paket add SentimentAnalyzer --version 3.0.0
#r "nuget: SentimentAnalyzer, 3.0.0"
#:package SentimentAnalyzer@3.0.0
#addin nuget:?package=SentimentAnalyzer&version=3.0.0Install as a Cake Addin
#tool nuget:?package=SentimentAnalyzer&version=3.0.0Install as a Cake Tool
๐ NuGet
๐ NuGet Downloads
๐ License: MIT
On-device (offline) Sentiment Analysis for .NET applications
A cross-platform, privacy-first library for sentiment analysis that runs entirely on-device without requiring internet connectivity.
dotnet add package SentimentAnalyzer.Core
using SentimentAnalyzer;
// Simple usage
var analyzer = new SentimentAnalyzer();
var result = analyzer.Analyze("I love this product!");
Console.WriteLine($"Sentiment: {result.Label}"); // Positive
Console.WriteLine($"Score: {result.Score:F2}"); // 0.87
Console.WriteLine($"Confidence: {result.Confidence:F2}"); // 0.74
dotnet add package SentimentAnalyzer.Core
dotnet add package SentimentAnalyzer.Onnx
using SentimentAnalyzer;
using SentimentAnalyzer.Onnx;
// Use TinyBERT for higher accuracy (embedded model, ~18MB)
var analyzer = SentimentAnalyzer.CreateBuilder()
.UseTinyBert()
.Build();
var result = analyzer.Analyze("This product is amazing!");
Console.WriteLine($"Sentiment: {result.Label}"); // Positive
Console.WriteLine($"Confidence: {result.Confidence:P0}"); // 99%
dotnet add package SentimentAnalyzer.Core
dotnet add package SentimentAnalyzer.Onnx.Multilingual
using SentimentAnalyzer;
using SentimentAnalyzer.Onnx.Multilingual;
// Use DistilBERT for multilingual support (downloads ~270MB model on first use)
var analyzer = SentimentAnalyzer.CreateBuilder()
.UseDistilBert()
.Build();
// Supports 104 languages!
var result = analyzer.Analyze("Ce produit est fantastique!"); // French
Console.WriteLine($"Sentiment: {result.Label}"); // Positive
// Also works with: Arabic, Chinese, German, Spanish, Hindi, Japanese, etc.
๐ฅ Note on DistilBERT Multilingual: The ~270MB model is automatically downloaded from GitHub Releases on first use and cached locally at
%LOCALAPPDATA%\SentimentAnalyzer\models\. Subsequent uses are fully offline. See full list of 104 supported languages.
dotnet add package SentimentAnalyzer
using SentimentAnalyzer;
// v1.x/v2.x API still works
var result = Sentiments.Predict("This product is amazing!");
Console.WriteLine($"Positive: {result.Prediction}"); // true
| Package | Size | Engine | Languages | Accuracy | Speed | Best For |
|---|---|---|---|---|---|---|
| SentimentAnalyzer.Core | <1MB | VADER (rule-based) | English | ~80% | โกโกโกโกโก | Mobile, IoT, speed-critical apps |
| SentimentAnalyzer.Onnx | ~18MB | TinyBERT (transformer) | English | ~94% | โกโกโกโก | High accuracy, embedded model |
| SentimentAnalyzer.Onnx.Multilingual | ~541MB | DistilBERT (transformer) | 104 languages | ~83% | โกโกโก | Multilingual, highest accuracy |
| SentimentAnalyzer | ~15MB | ML.NET (traditional ML) | English | ~85% | โกโกโกโก | Backward compatibility |
Speed ratings: โกโกโกโกโก (fastest) to โก (slowest)
| Platform | Core | Onnx (TinyBERT) | Onnx.Multilingual | Legacy |
|---|---|---|---|---|
| .NET Standard 2.0 | โ | โ | โ | โ |
| .NET 8 (LTS) | โ | โ | โ | โ |
| .NET 10 (LTS) | โ | โ | โ | โ |
| .NET MAUI | โ | โ | โ | โ |
| Blazor WASM | โ | โ | โ | โ |
| Blazor Server | โ | โ | โ | โ |
| Unity | โ | โ ๏ธ | โ | โ |
Note: ONNX models require native C++ libraries and cannot run in Blazor WebAssembly. Use Core (VADER) for WASM or Blazor Server for ML models.
| Use Case | Recommended Package |
|---|---|
| Mobile apps (MAUI, Xamarin) | Core (VADER) or Onnx (TinyBERT) |
| IoT/Edge devices | Core (VADER) |
| Blazor WebAssembly | Core (VADER) |
| Speed-critical applications | Core (VADER) |
| High accuracy (English) | Onnx (TinyBERT) |
| Multilingual support | Onnx.Multilingual (DistilBERT) |
| Social media analysis | Core (VADER - optimized for social text with emojis) |
| Customer reviews | Onnx (TinyBERT) or Onnx.Multilingual |
| Enterprise/existing apps | Legacy (ML.NET) |
// Default constructor (uses VADER engine)
var analyzer = new SentimentAnalyzer();
// With options
var analyzer = new SentimentAnalyzer(SentimentAnalyzerOptions.Binary);
// Builder pattern
var analyzer = SentimentAnalyzer.CreateBuilder()
.WithNeutralThresholds(0.3, 0.7) // Customize neutral zone
.Build();
| Property | Type | Description |
|---|---|---|
Text |
string | Original input text |
Label |
SentimentLabel | Positive, Neutral, or Negative |
Score |
double | Normalized score (0-1) |
Confidence |
double | Prediction confidence (0-1) |
Engine |
string | Engine name ("Vader", "TinyBert", "DistilBert") |
IsPositive |
bool | Shorthand for Label == Positive |
IsNegative |
bool | Shorthand for Label == Negative |
IsNeutral |
bool | Shorthand for Label == Neutral |
// Presets
SentimentAnalyzerOptions.Default // Neutral zone: 0.4-0.6
SentimentAnalyzerOptions.Binary // No neutral (positive/negative only)
SentimentAnalyzerOptions.Strict // Narrow neutral: 0.45-0.55
SentimentAnalyzerOptions.Lenient // Wide neutral: 0.3-0.7
var analyzer = new SentimentAnalyzer();
var reviews = new[] {
"Great product!",
"Terrible service.",
"It's okay I guess."
};
var results = analyzer.AnalyzeBatch(reviews);
foreach (var result in results)
{
Console.WriteLine($"{result.Label}: {result.Text}");
}
// Implement ISentimentEngine for custom engines
public class MyCustomEngine : ISentimentEngine
{
public string Name => "Custom";
public SentimentResult Analyze(string text) { /* ... */ }
public IReadOnlyList<SentimentResult> AnalyzeBatch(IEnumerable<string> texts) { /* ... */ }
public void Dispose() { }
}
// Use with builder
var analyzer = SentimentAnalyzer.CreateBuilder()
.WithEngine(_ => new MyCustomEngine())
.Build();
```
### TinyBERT with Custom Options
```csharp
using SentimentAnalyzer.Onnx;
using Microsoft.ML.OnnxRuntime;
// Configure ONNX Runtime session options
var sessionOptions = new SessionOptions
{
GraphOptimizationLevel = GraphOptimizationLevel.ORT_ENABLE_ALL,
ExecutionMode = ExecutionMode.ORT_PARALLEL
};
var analyzer = SentimentAnalyzer.CreateBuilder()
.UseTinyBert(sessionOptions)
.WithBinaryClassification() // Disable neutral classification
.Build();
using SentimentAnalyzer.Onnx.Multilingual;
var progress = new Progress<double>(p =>
Console.WriteLine($"Downloading model: {p:P0}"));
var analyzer = await SentimentAnalyzer.CreateBuilder()
.UseDistilBertMultilingualAsync(progress: progress);
// Model is now cached locally, subsequent uses are offline
This project is licensed under the MIT License - see the file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
| Engine | Package | Accuracy | Speed | Size | Languages |
|---|---|---|---|---|---|
| VADER | Core | ~80% | โกโกโกโกโก | <1MB | English |
| TinyBERT | Onnx | ~94% | โกโกโกโก | ~18MB | English |
| DistilBERT | Onnx.Multilingual | ~83% | โกโกโก | ~541MB | 104 |
| ML.NET (Legacy) | SentimentAnalyzer | ~85% | โกโกโกโก | ~15MB | English |
Speed ratings: โกโกโกโกโก (fastest) to โก (slowest). Accuracy tested on various datasets. ๏ฟฝ Migration from v2.x
Sentiments.Predict():No changes needed! The legacy API continues to work:
<PackageReference Include="SentimentAnalyzer" Version="3.0.0" />
// Before (ML.NET, ~15MB)
var result = Sentiments.Predict("I love this!");
// After (VADER, <1MB - fastest)
var analyzer = new SentimentAnalyzer();
var result = analyzer.Analyze("I love this!");
// Result now has more properties:
// result.Label (enum), result.Confidence, result.IsPositive, etc.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 4 NuGet packages that depend on SentimentAnalyzer:
| Package | Downloads |
|---|---|
|
Bot.Builder.Community.Middleware.SentimentAnalysis
This middleware uses Cognitive Services Sentiment Analysis to identify the sentiment of each inbound message and make it available for your bot or other middleware component. |
|
|
Bot.Builder.Community.Components.Middleware.SentimentAnalysis
Sentiment Analysis Middleware component for Bot Framework Composer and v4 Bot Builder SDK. Enables you to find out what customer think of brand or topic by analyzing raw text for clues about positive or negative sentiment. This component can extract the sentiment powered by SentimentAnalyzer which encapsulates both offline (powered by ML.NET) and online (powered by Azure Cognitive Services) sentiment analysis. |
|
|
Bot.Builder.Community.Components.Middleware.Testinghttp
Sentiment Analysis Middleware component for Bot Framework Composer and v4 Bot Builder SDK. Enables you to find out what customer think of brand or topic by analyzing raw text for clues about positive or negative sentiment. This component can extract the sentiment powered by SentimentAnalyzer which encapsulates both offline (powered by ML.NET) and online (powered by Azure Cognitive Services) sentiment analysis. |
|
|
Bot.Builder.Community.Components.Middleware.Httpcall
Sentiment Analysis Middleware component for Bot Framework Composer and v4 Bot Builder SDK. Enables you to find out what customer think of brand or topic by analyzing raw text for clues about positive or negative sentiment. This component can extract the sentiment powered by SentimentAnalyzer which encapsulates both offline (powered by ML.NET) and online (powered by Azure Cognitive Services) sentiment analysis. |
Showing the top 1 popular GitHub repositories that depend on SentimentAnalyzer:
| Repository | Stars |
|---|---|
|
BotBuilderCommunity/botbuilder-community-dotnet
Part of the Bot Builder Community Project. Repository for extensions for the Bot Builder .NET SDK, including middleware, dialogs, recognizers and more.
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 3.0.0 | 318 | 1/26/2026 | |
| 2.0.0 | 134 | 1/21/2026 | |
| 1.2.3 | 2,751 | 9/28/2021 | |
| 1.2.2 | 3,905 | 4/9/2021 | 1.2.2 is deprecated because it is no longer maintained. |
| 1.2.1 | 938 | 4/6/2021 | 1.2.1 is deprecated because it is no longer maintained. |
| 1.2.0 | 941 | 4/6/2021 | 1.2.0 is deprecated because it is no longer maintained. |
| 1.1.1 | 3,328 | 3/4/2021 | 1.1.1 is deprecated because it is no longer maintained. |
| 1.1.0 | 11,939 | 10/2/2019 | 1.1.0 is deprecated because it is no longer maintained. |
| 1.0.5 | 1,860 | 5/14/2019 | 1.0.5 is deprecated because it is no longer maintained. |
| 1.0.4 | 5,401 | 4/22/2019 | 1.0.4 is deprecated because it is no longer maintained. |
v3.0 introduces a modular package family. This package (ML.NET) continues to work for existing users. New packages: SentimentAnalyzer.Core (VADER, lightweight) and SentimentAnalyzer.Onnx (transformers, accurate).