ml_sentiment_simple 1.0.0
ml_sentiment_simple: ^1.0.0 copied to clipboard
A simple multilingual (Turkish + English) sentiment analyzer based on word scoring.
π ml_sentiment_simple #
ml_sentiment_simple is a lightweight and multilingual (πΉπ· Turkish + πΊπΈ English) word-level sentiment analysis library for Dart and Flutter.
It analyzes a given text and classifies it as positive, negative, or neutral based on predefined sentiment lexicons.
β Features #
- π¦ Simple word-based sentiment classification
- π Supports Turkish, English, or both
- π§© Easily extendable with custom word lists
- β‘ Zero dependencies, blazing fast
- β Fully tested and production-ready
π Installation #
Add the following line to your pubspec.yaml:
dependencies:
ml_sentiment_simple: ^1.0.0
Then run:
flutter pub get
π‘ Usage #
import 'package:ml_sentiment_simple/ml_sentiment_simple.dart';
void main() {
final analyzer = SentimentAnalyzer();
final result = analyzer.analyze("This is awesome but also terrible.");
print(result); // Label: neutral, Score: 0.0, ...
}
You can also customize the lexicon:
final customAnalyzer = SentimentAnalyzer(
lexicon: WordSentimentLexicon(
language: LexiconLanguage.both,
customPositiveWords: {'wonderful'},
customNegativeWords: {'disaster'},
),
);
final result = customAnalyzer.analyze("It was a wonderful disaster.");
print(result); // Label: neutral, Score: 0.0
π§ͺ Testing #
To run unit tests:
dart test
π API #
SentimentAnalyzer #
Main entry point for analyzing sentences.
WordSentimentLexicon #
Contains sentiment word lists (positive/negative), can be customized.
LexiconLanguage #
Enum to specify language: turkish, english, or both.
SentimentResult #
Model class with fields: label, score, positiveCount, negativeCount, totalWords.
π License #
This project is licensed under the MIT License β see the LICENSE file for details.
π€ Author #
Developed by Mehmet Γelik