PerSent 0.2.1__tar.gz → 0.2.3__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.1
3
+ Version: 0.2.3
4
4
  Summary: Persian Sentiment Analysis Toolkit
5
5
  Home-page: https://github.com/RezaGooner/PerSent
6
6
  Author: RezaGooner
@@ -111,3 +111,49 @@ class CommentAnalyzer:
111
111
  """reload from file"""
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
+
115
+ def csvPredict(self, input_csv, output_path, text_column=0):
116
+ """
117
+ Analyze sentiment for comments in a CSV file and save results
118
+
119
+ Parameters:
120
+ input_csv (str): Path to input CSV file
121
+ output_path (str): Path to save output CSV file
122
+ text_column (str/int, optional): Name or index (0-based) of column containing comments.
123
+ Defaults to 0 (first column).
124
+ """
125
+ try:
126
+ # Read input CSV
127
+ df = pd.read_csv(input_csv)
128
+
129
+ # Determine the correct column
130
+ if isinstance(text_column, int):
131
+ # Handle negative indices
132
+ if text_column < 0:
133
+ text_column = len(df.columns) + text_column
134
+
135
+ if text_column >= len(df.columns) or text_column < 0:
136
+ raise ValueError(f"Column index {text_column} is out of range")
137
+
138
+ column_name = df.columns[text_column]
139
+ else:
140
+ if text_column not in df.columns:
141
+ raise ValueError(f"Column '{text_column}' not found in CSV file")
142
+ column_name = text_column
143
+
144
+ # Analyze each comment
145
+ tqdm.pandas(desc="Analyzing comments")
146
+ df['sentiment'] = df[column_name].progress_apply(self.predict)
147
+
148
+ # Save results
149
+ df.to_csv(output_path, index=False, encoding='utf-8-sig')
150
+ print(f"Results saved to {output_path}")
151
+
152
+ return df
153
+
154
+ except Exception as e:
155
+ print(f"Error: {str(e)}")
156
+ return None
157
+
158
+
159
+ # Github : RezaGooner
@@ -1,4 +1,4 @@
1
1
  from .CommentAnalyzer import CommentAnalyzer
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.3"
4
4
  __all__ = ['CommentAnalyzer']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PerSent
3
- Version: 0.2.1
3
+ Version: 0.2.3
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.1",
8
+ version="0.2.3",
9
9
  author="RezaGooner",
10
10
  author_email="RezaAsadiProgrammer@Gmail.com",
11
11
  description="Persian Sentiment Analysis Toolkit",
File without changes
File without changes