搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.9

dart_sentiment

Dart Sentiment 是一個 Dart 模組,使用 AFINN-165 詞表和表情符號情感排名來對任意輸入文字區塊進行情感分析。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
168
喜歡數
36
Pub 分數
145

安裝套件

flutter pub add dart_sentiment

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Dart Sentiment 是一個輕量級的 Dart 套件,使用 AFINN-165 詞表與 Emoji 情感評分對文字進行情感分析。它為輸入文字分配情感分數,讓開發者能夠評估使用者產生內容的情感基調。此套件支援 Android、iOS、Web、macOS、Windows 與 Linux 等多個平台,非常適合需要即時情感評估的跨平台應用。其設計簡潔高效,除核心 Dart 庫外無需任何外部相依性。

適用情境

  • 分析用戶評論
  • 監控社交媒體情緒
  • 評估客戶反饋
  • 增強聊天機器人的回覆
  • 追蹤品牌認知

主要特色

  • 使用 AFINN-165 和表情符號情感資料
  • 跨平台相容性
  • 簡單 API 結合
  • 即時情感評分
  • 無外部依賴

適合對象

  • 行動和網頁應用
  • 客戶體驗工具
  • 情感驅動的分析
  • 社群媒體監控
  • 反饋系統

使用建議

  • 限於預定義詞庫
  • 不支援自定情緒詞典
  • 可能無法捕捉上下文或諷刺
  • 準確性取決於輸入文本的樣式
  • 不適用於多語言情感分析

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Dart Sentiment

Flutter Community: dart_sentiment

pub package

AFINN-based sentiment analysis for dart

Dart Sentiment is a dart package that uses
the AFINN-165
wordlist
and Emoji Sentiment Ranking
to perform sentiment analysis on arbitrary
blocks of input text. Dart Sentiment provides several things:

  • Provide Language support for English, Italian, French and German.
  • Provide support for various emojis.
  • Based on analysis of text, provide an integer value in the range -n to +n (see details below)

Installation

add following dependency to your pubspec.yaml

  
dependencies:    
   dart_sentiment: <latest-version>  
   

Example


 import 'package:dart_sentiment/dart_sentiment.dart';    
 void main() {
 
	 final sentiment = Sentiment();    
    
	 print(sentiment.analysis("The cake she made was terrible 😐"));    
    
	 print(sentiment.analysis("The cake she made was terrible 😐", emoji: true));    
    
	 print(sentiment.analysis("I love cats, but I am allergic to them.",));    
    
	 print(sentiment.analysis("J'adore les chats, mais j'y suis allergique.",    
	 languageCode: LanguageCode.french));    
    
	print(sentiment.analysis("Le gâteau qu'elle a fait était horrible 😐",    
	emoji: true, languageCode: LanguageCode.french)); 

}  

Function defination
Param Description
String text Input phrase to analyze
bool emoji = false Input emoji is present in the phrase to analyze
LanguageCode languageCode = LanguageCode.english Language to use for sentiment analysis. LanguageCode { english, italian, french, german }

How it works

AFINN

AFINN is a list of words rated for valence with an integer between minus five (negative) and plus
five (positive). Sentiment analysis is performed by cross-checking the string tokens (words, emojis)
with the AFINN list and getting their respective scores. The comparative score is
simply: sum of each token / number of tokens. So for example let's take the following:

I love cats, but I am allergic to them.

That string results in the following:

{
    score: 1, 
	comparative: 0.1111111111111111,  
    tokens: [    
       "i",    
       "love",    
       "cats",    
       "but",    
       "i",    
       "am",    
       "allergic",    
       "to",    
       "them"    
    ],
    positive: [[love, 3]], 
    negative: [[allergic, 2]]
} 
  • Returned Objects
    • Score: Score calculated by adding the sentiment values of recognized words.
    • Comparative: Comparative score of the input string.
    • Token: All the tokens like words or emojis found in the input string.
    • Words: List of words from input string that were found in AFINN list.
    • Positive: List of positive words in input string that were found in AFINN list.
    • Negative: List of negative words in input string that were found in AFINN list.

In this case, love has a value of 3, allergic has a value of -2, and the remaining tokens are
neutral with a value of 0. Because the string has 9 tokens the resulting comparative score looks
like: (3 + -2) / 9 = 0.111111111

This approach leaves you with a mid-point of 0 and the upper and lower bounds are constrained to
positive and negative 5 respectively. For example, let's imagine an incredibly "positive" string
with 200 tokens and where each token has an AFINN score of 5. Our resulting comparative score would
look like this:

(max positive score * number of tokens) / number of tokens (5 * 200) / 200 = 5

Contribute

If you have any suggestions, improvements or issues, feel free to contribute to this project. You
can either submit a new issue or propose a pull request. Direct your pull requests into the dev
branch.

License

Dart Sentiment is released under
the MIT License

Credit

Dart Sentiment inspired by the Javascript
package sentiment

About me

I am India based flutter developer

pub package [](mailto:akashlilhare14@gmail.com) twitter website

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案