패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소akashlilhare/dart_sentiment

dart_sentiment

Dart Sentiment은 AFINN-165 단어 목록과 이모지 감정 순위를 사용하여 임의의 입력 텍스트 블록에 대한 감성 분석을 수행하는 Dart 모듈입니다.

dart_sentiment 프로젝트 이미지
스타
9
포크
2
최근 푸시(UTC)
2023. 5. 23.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

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

Akash Lilhare GitHub avatar
GitHub 작성자

Akash Lilhare ↗

Mobile Product Engineer · Flutter + AI · Founder of Beast Fitness (300K downloads)

Bengaluru, India공식 웹사이트 ↗
언어Dart

분류

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗