EmoTFIDF 1.2.7__tar.gz → 1.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,8 @@ import nltk
6
6
  from nltk.corpus import stopwords
7
7
  import urllib.request
8
8
  import json
9
+ import matplotlib.pyplot as plt
10
+ import seaborn as sns
9
11
 
10
12
  nltk.download('wordnet')
11
13
  nltk.download('punkt')
@@ -166,3 +168,57 @@ class EmoTFIDF:
166
168
  for key in em_frequencies.keys():
167
169
  em_percent.update({key: round(float(em_frequencies[key]) / float(sum_values), 3)})
168
170
  self.em_tfidf = em_percent
171
+
172
+ def plot_emotion_distribution(self):
173
+ """
174
+ Plot the distribution of emotions found in the text.
175
+ """
176
+ if not hasattr(self, 'em_frequencies'):
177
+ raise AttributeError("Emotion frequencies not found. Please run set_text() method first.")
178
+
179
+ emotions = list(self.em_frequencies.keys())
180
+ frequencies = list(self.em_frequencies.values())
181
+
182
+ plt.figure(figsize=(10, 5))
183
+ sns.barplot(x=emotions, y=frequencies)
184
+ plt.title('Emotion Distribution')
185
+ plt.xlabel('Emotions')
186
+ plt.ylabel('Frequency')
187
+ plt.show()
188
+
189
+ def plot_top_tfidf(self, top_n=20):
190
+ """
191
+ Plot the top N words based on their TF-IDF scores.
192
+
193
+ Args:
194
+ top_n (int): Number of top words to display. Default is 20.
195
+ """
196
+ if not hasattr(self, 'tfid'):
197
+ raise AttributeError("TF-IDF data not found. Please run compute_tfidf() method first.")
198
+
199
+ top_words = self.tfid.sum().sort_values(ascending=False).head(top_n)
200
+
201
+ plt.figure(figsize=(10, 5))
202
+ sns.barplot(x=top_words.index, y=top_words.values)
203
+ plt.title(f'Top {top_n} Words by TF-IDF Score')
204
+ plt.xlabel('Words')
205
+ plt.ylabel('TF-IDF Score')
206
+ plt.xticks(rotation=45)
207
+ plt.show()
208
+
209
+ def plot_emotfidf(self):
210
+ """
211
+ Plot the TF-IDF weighted emotion scores.
212
+ """
213
+ if not hasattr(self, 'em_tfidf'):
214
+ raise AttributeError("TF-IDF weighted emotion scores not found. Please run get_emotfidf() method first.")
215
+
216
+ emotions = list(self.em_tfidf.keys())
217
+ scores = list(self.em_tfidf.values())
218
+
219
+ plt.figure(figsize=(10, 5))
220
+ sns.barplot(x=emotions, y=scores)
221
+ plt.title('TF-IDF Weighted Emotion Scores')
222
+ plt.xlabel('Emotions')
223
+ plt.ylabel('Weighted Score')
224
+ plt.show()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: EmoTFIDF
3
- Version: 1.2.7
3
+ Version: 1.2.8
4
4
  Summary: A library to extract emotions using two methods, 1- Using lexicon based, counting frequency of emotion2- Integrating TFIDF to add a contextNote that lexicon license is for research purposes only.
5
5
  Home-page: https://github.com/mmsa/emotfidf
6
6
  Author: mmsa12
@@ -75,6 +75,59 @@ df2 = df['emotions'].apply(pd.Series)
75
75
  final_df = pd.concat([df,df2],axis=1)
76
76
  ```
77
77
 
78
+ #Plotting Emotion Distribution
79
+ You can visualize the distribution of emotions using the plot_emotion_distribution method:
80
+
81
+ ```python
82
+ from EmoTFIDF import EmoTFIDF
83
+
84
+ comment = "I had a GREAT week, thanks to YOU! I am very happy today."
85
+
86
+ emTFIDF = EmoTFIDF()
87
+ emTFIDF.set_text(comment)
88
+ emTFIDF.plot_emotion_distribution()
89
+ ```
90
+
91
+ #Plotting Top TFIDF Words
92
+ To visualize the top N words by their TFIDF scores:
93
+ ```python
94
+ import pandas as pd
95
+ from EmoTFIDF import EmoTFIDF
96
+
97
+ # Assuming df is your DataFrame and it has a column 'text'
98
+ emTFIDF = EmoTFIDF()
99
+ emTFIDF.compute_tfidf(df['text'])
100
+ emTFIDF.plot_top_tfidf(top_n=20)
101
+
102
+
103
+ ```
104
+ #Plotting TFIDF Weighted Emotion Scores
105
+ To visualize the TFIDF weighted emotion scores:
106
+ ```python
107
+ from EmoTFIDF import EmoTFIDF
108
+
109
+ comment = "I had a GREAT week, thanks to YOU! I am very happy today."
110
+
111
+ emTFIDF = EmoTFIDF()
112
+ emTFIDF.set_text(comment)
113
+ emTFIDF.get_emotfidf()
114
+ emTFIDF.plot_emotfidf()
115
+
116
+ ```
117
+
118
+ ##Update 1.3.0
119
+
120
+ Introduced new plotting features to visualize the distribution of emotions, top TFIDF words, and TFIDF weighted emotion scores.
121
+
122
+ New Methods:
123
+ plot_emotion_distribution(): Visualizes the distribution of emotions in the text.
124
+ plot_top_tfidf(top_n=20): Visualizes the top N words by their TFIDF scores.
125
+ plot_emotfidf(): Visualizes the TFIDF weighted emotion scores.
126
+ These features enhance the interpretability of the emotion analysis by providing insightful visualizations.
127
+
128
+
129
+
130
+
78
131
  ##Update 1.0.7
79
132
 
80
133
  Thanks to [artofchores](https://www.reddit.com/user/artofchores/), from Reddit for his feedback.
@@ -1,3 +1,5 @@
1
1
  nltk
2
2
  scikit-learn
3
3
  pandas
4
+ matplotlib
5
+ seaborn
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: EmoTFIDF
3
- Version: 1.2.7
3
+ Version: 1.2.8
4
4
  Summary: A library to extract emotions using two methods, 1- Using lexicon based, counting frequency of emotion2- Integrating TFIDF to add a contextNote that lexicon license is for research purposes only.
5
5
  Home-page: https://github.com/mmsa/emotfidf
6
6
  Author: mmsa12
@@ -75,6 +75,59 @@ df2 = df['emotions'].apply(pd.Series)
75
75
  final_df = pd.concat([df,df2],axis=1)
76
76
  ```
77
77
 
78
+ #Plotting Emotion Distribution
79
+ You can visualize the distribution of emotions using the plot_emotion_distribution method:
80
+
81
+ ```python
82
+ from EmoTFIDF import EmoTFIDF
83
+
84
+ comment = "I had a GREAT week, thanks to YOU! I am very happy today."
85
+
86
+ emTFIDF = EmoTFIDF()
87
+ emTFIDF.set_text(comment)
88
+ emTFIDF.plot_emotion_distribution()
89
+ ```
90
+
91
+ #Plotting Top TFIDF Words
92
+ To visualize the top N words by their TFIDF scores:
93
+ ```python
94
+ import pandas as pd
95
+ from EmoTFIDF import EmoTFIDF
96
+
97
+ # Assuming df is your DataFrame and it has a column 'text'
98
+ emTFIDF = EmoTFIDF()
99
+ emTFIDF.compute_tfidf(df['text'])
100
+ emTFIDF.plot_top_tfidf(top_n=20)
101
+
102
+
103
+ ```
104
+ #Plotting TFIDF Weighted Emotion Scores
105
+ To visualize the TFIDF weighted emotion scores:
106
+ ```python
107
+ from EmoTFIDF import EmoTFIDF
108
+
109
+ comment = "I had a GREAT week, thanks to YOU! I am very happy today."
110
+
111
+ emTFIDF = EmoTFIDF()
112
+ emTFIDF.set_text(comment)
113
+ emTFIDF.get_emotfidf()
114
+ emTFIDF.plot_emotfidf()
115
+
116
+ ```
117
+
118
+ ##Update 1.3.0
119
+
120
+ Introduced new plotting features to visualize the distribution of emotions, top TFIDF words, and TFIDF weighted emotion scores.
121
+
122
+ New Methods:
123
+ plot_emotion_distribution(): Visualizes the distribution of emotions in the text.
124
+ plot_top_tfidf(top_n=20): Visualizes the top N words by their TFIDF scores.
125
+ plot_emotfidf(): Visualizes the TFIDF weighted emotion scores.
126
+ These features enhance the interpretability of the emotion analysis by providing insightful visualizations.
127
+
128
+
129
+
130
+
78
131
  ##Update 1.0.7
79
132
 
80
133
  Thanks to [artofchores](https://www.reddit.com/user/artofchores/), from Reddit for his feedback.
@@ -61,6 +61,59 @@ df2 = df['emotions'].apply(pd.Series)
61
61
  final_df = pd.concat([df,df2],axis=1)
62
62
  ```
63
63
 
64
+ #Plotting Emotion Distribution
65
+ You can visualize the distribution of emotions using the plot_emotion_distribution method:
66
+
67
+ ```python
68
+ from EmoTFIDF import EmoTFIDF
69
+
70
+ comment = "I had a GREAT week, thanks to YOU! I am very happy today."
71
+
72
+ emTFIDF = EmoTFIDF()
73
+ emTFIDF.set_text(comment)
74
+ emTFIDF.plot_emotion_distribution()
75
+ ```
76
+
77
+ #Plotting Top TFIDF Words
78
+ To visualize the top N words by their TFIDF scores:
79
+ ```python
80
+ import pandas as pd
81
+ from EmoTFIDF import EmoTFIDF
82
+
83
+ # Assuming df is your DataFrame and it has a column 'text'
84
+ emTFIDF = EmoTFIDF()
85
+ emTFIDF.compute_tfidf(df['text'])
86
+ emTFIDF.plot_top_tfidf(top_n=20)
87
+
88
+
89
+ ```
90
+ #Plotting TFIDF Weighted Emotion Scores
91
+ To visualize the TFIDF weighted emotion scores:
92
+ ```python
93
+ from EmoTFIDF import EmoTFIDF
94
+
95
+ comment = "I had a GREAT week, thanks to YOU! I am very happy today."
96
+
97
+ emTFIDF = EmoTFIDF()
98
+ emTFIDF.set_text(comment)
99
+ emTFIDF.get_emotfidf()
100
+ emTFIDF.plot_emotfidf()
101
+
102
+ ```
103
+
104
+ ##Update 1.3.0
105
+
106
+ Introduced new plotting features to visualize the distribution of emotions, top TFIDF words, and TFIDF weighted emotion scores.
107
+
108
+ New Methods:
109
+ plot_emotion_distribution(): Visualizes the distribution of emotions in the text.
110
+ plot_top_tfidf(top_n=20): Visualizes the top N words by their TFIDF scores.
111
+ plot_emotfidf(): Visualizes the TFIDF weighted emotion scores.
112
+ These features enhance the interpretability of the emotion analysis by providing insightful visualizations.
113
+
114
+
115
+
116
+
64
117
  ##Update 1.0.7
65
118
 
66
119
  Thanks to [artofchores](https://www.reddit.com/user/artofchores/), from Reddit for his feedback.
@@ -19,7 +19,7 @@ class Install(_install):
19
19
 
20
20
  setuptools.setup(
21
21
  name="EmoTFIDF",
22
- version="1.2.7",
22
+ version="1.2.8",
23
23
  author="mmsa12",
24
24
  author_email="mmsa12@gmail.com",
25
25
  description="A library to extract emotions using two methods, 1- Using lexicon based, counting frequency of emotion"
@@ -29,7 +29,7 @@ setuptools.setup(
29
29
  long_description_content_type="text/markdown",
30
30
  url="https://github.com/mmsa/emotfidf",
31
31
  packages=setuptools.find_packages(),
32
- install_requires=['nltk', 'scikit-learn', 'pandas'],
32
+ install_requires=['nltk', 'scikit-learn', 'pandas', 'matplotlib', 'seaborn'],
33
33
  include_package_data=True,
34
34
  py_modules=["EmoTFIDF"],
35
35
  setup_requires=['nltk'],
File without changes
File without changes
File without changes
File without changes