PerSent 0.2.3__tar.gz → 0.2.4__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.

Potentially problematic release.


This version of PerSent might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PerSent
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Persian Sentiment Analysis Toolkit
5
5
  Home-page: https://github.com/RezaGooner/PerSent
6
6
  Author: RezaGooner
@@ -112,7 +112,7 @@ class CommentAnalyzer:
112
112
  self.classifier = joblib.load(os.path.join(self.model_dir, 'classifier.joblib'))
113
113
  self.vectorizer = Word2Vec.load(os.path.join(self.model_dir, 'word2vec.model'))
114
114
 
115
- def csvPredict(self, input_csv, output_path, text_column=0):
115
+ def csvPredict(self, input_csv, output_path, summary_path=None, text_column=0):
116
116
  """
117
117
  Analyze sentiment for comments in a CSV file and save results
118
118
 
@@ -121,6 +121,8 @@ class CommentAnalyzer:
121
121
  output_path (str): Path to save output CSV file
122
122
  text_column (str/int, optional): Name or index (0-based) of column containing comments.
123
123
  Defaults to 0 (first column).
124
+ summary_path (str, optional): Path to save prediction summary report.
125
+ If None, no summary will be saved.
124
126
  """
125
127
  try:
126
128
  # Read input CSV
@@ -149,11 +151,49 @@ class CommentAnalyzer:
149
151
  df.to_csv(output_path, index=False, encoding='utf-8-sig')
150
152
  print(f"Results saved to {output_path}")
151
153
 
154
+ # Generate and save summary if requested
155
+ if summary_path:
156
+ summary = self._generate_summary(df)
157
+ summary.to_csv(summary_path, index=False, encoding='utf-8-sig')
158
+ print(f"Summary report saved to {summary_path}")
159
+
152
160
  return df
153
161
 
154
162
  except Exception as e:
155
163
  print(f"Error: {str(e)}")
156
164
  return None
157
165
 
166
+ def _generate_summary(self, df):
167
+ """Generate prediction summary statistics"""
168
+ # Count each sentiment
169
+ counts = df['sentiment'].value_counts().to_dict()
170
+
171
+ # Create summary dataframe
172
+ summary = pd.DataFrame({
173
+ 'Category': [
174
+ 'Recommended',
175
+ 'Not Recommended',
176
+ 'No Idea',
177
+ 'Total',
178
+ 'Model Accuracy'
179
+ ],
180
+ 'Count': [
181
+ counts.get('recommended', 0),
182
+ counts.get('not_recommended', 0),
183
+ counts.get('no_idea', 0),
184
+ len(df),
185
+ 'N/A' # Accuracy needs to be calculated during training
186
+ ],
187
+ 'Percentage': [
188
+ f"{100 * counts.get('recommended', 0) / len(df):.2f}%",
189
+ f"{100 * counts.get('not_recommended', 0) / len(df):.2f}%",
190
+ f"{100 * counts.get('no_idea', 0) / len(df):.2f}%",
191
+ '100%',
192
+ 'N/A'
193
+ ]
194
+ })
195
+
196
+ return summary
197
+
158
198
 
159
199
  # Github : RezaGooner
@@ -1,4 +1,4 @@
1
1
  from .CommentAnalyzer import CommentAnalyzer
2
2
 
3
- __version__ = "0.2.3"
3
+ __version__ = "0.2.4"
4
4
  __all__ = ['CommentAnalyzer']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PerSent
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Persian Sentiment Analysis Toolkit
5
5
  Home-page: https://github.com/RezaGooner/PerSent
6
6
  Author: RezaGooner
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="PerSent",
8
- version="0.2.3",
8
+ version="0.2.4",
9
9
  author="RezaGooner",
10
10
  author_email="RezaAsadiProgrammer@Gmail.com",
11
11
  description="Persian Sentiment Analysis Toolkit",
File without changes
File without changes