Introducing ml_sentiment_simple
: A Multilingual Sentiment Analysis Library for Dart & Flutter
✨ Lightweight, customizable, and dependency-free. Analyze positive, negative, and neutral sentiments in Turkish 🇹🇷 and English 🇺🇸 texts with just a few lines of Dart code.
🚀 What is ml_sentiment_simple
?
ml_sentiment_simple
is a simple but powerful sentiment analysis package for Dart and Flutter developers. It uses a word-based lexicon method to determine the emotional tone of a sentence. Unlike complex ML models, this tool is blazing fast, runs offline, and is fully customizable.
✅ Key Features
- 🌐 Multilingual support – Turkish 🇹🇷 and English 🇺🇸 out of the box
- 🧠 Zero dependencies – works with core Dart libraries only
- 🧩 Custom lexicons – extend the word list with your own vocabulary
- 🚀 Ultra-lightweight – ideal for mobile and embedded apps
- 📦 Available on pub.dev
🔧 Installation
Add this to your pubspec.yaml
:
dependencies:
ml_sentiment_simple: ^1.0.0
Then run:
flutter pub get
💡 Usage Example
import 'package:ml_sentiment_simple/ml_sentiment_simple.dart';
void main() {
final analyzer = SentimentAnalyzer();
final result = analyzer.analyze("This is amazing but also a bit disappointing.");
print(result.label); // → neutral
print(result.score); // → 0.0
}
You can also customize the word list:
final customAnalyzer = SentimentAnalyzer(
lexicon: WordSentimentLexicon(
language: LexiconLanguage.both,
customPositiveWords: {'delightful'},
customNegativeWords: {'disaster'},
),
);
🧪 Sentiment Scoring Logic
The score is computed as:
(positive - negative) / totalSentimentWords
Resulting in:
-
positive
if score > 0 -
negative
if score < 0 -
neutral
otherwise
This is extremely useful for feedback apps, chatbots, comment analysis, or social media monitoring tools.
📦 Explore the Package
- 👉 Pub.dev: ml_sentiment_simple
- 💻 GitHub: github.com/CelkMehmett/ml_sentiment_simple
🙌 Contributions Welcome!
I built this package to solve basic NLP needs on mobile without heavy ML models.
If you want to help expand lexicons or add new features, feel free to contribute or open an issue!
Thanks for reading — I hope this helps other Dart devs build smarter apps!
📌 Tags:
dart
, flutter
, nlp
, sentiment-analysis
, open-source
, pub-dev
Top comments (0)