This repository was archived by the owner on Jun 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 11from textblob import TextBlob
22
3+
34class SentimentAnalyzer :
45 def __init__ (self ):
56 pass
6-
7+
78 def get_sentiment (self , sentence : str ) -> str :
89 polarity = self ._get_polarity (sentence )
910 if polarity > 0 :
@@ -12,23 +13,23 @@ def get_sentiment(self, sentence: str) -> str:
1213 return "negative"
1314 else :
1415 return "neutral"
15-
16+
1617 def get_polarity_score (self , sentence : str ) -> float :
1718 return self ._get_polarity (sentence )
18-
19+
1920 def get_subjectivity_score (self , sentence : str ) -> float :
2021 return self ._get_subjectivity (sentence )
21-
22+
2223 def is_neutral (self , sentence : str ) -> bool :
2324 return self .get_sentiment (sentence ) == "neutral"
24-
25+
2526 def is_positive (self , sentence : str ) -> bool :
2627 return self .get_sentiment (sentence ) == "positive"
2728
2829 def _get_polarity (self , sentence : str ) -> float :
2930 analysis = TextBlob (sentence )
3031 return analysis .sentiment .polarity
31-
32+
3233 def _get_subjectivity (self , sentence : str ) -> float :
3334 analysis = TextBlob (sentence )
3435 return analysis .sentiment .subjectivity
You can’t perform that action at this time.
0 commit comments