PerSent 0.2.1__tar.gz → 0.2.2__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.2
4
4
  Summary: Persian Sentiment Analysis Toolkit
5
5
  Home-page: https://github.com/RezaGooner/PerSent
6
6
  Author: RezaGooner
@@ -111,3 +111,41 @@ 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='body'):
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, optional): Name of column containing comments. Defaults to 'body'.
123
+ """
124
+ try:
125
+ # Read input CSV
126
+ df = pd.read_csv(input_csv)
127
+
128
+ # Check if specified column exists
129
+ if text_column not in df.columns:
130
+ # If only one column exists, use it regardless of name
131
+ if len(df.columns) == 1:
132
+ text_column = df.columns[0]
133
+ else:
134
+ raise ValueError(f"Column '{text_column}' not found in CSV file")
135
+
136
+ # Analyze each comment
137
+ tqdm.pandas(desc="Analyzing comments")
138
+ df['sentiment'] = df[text_column].progress_apply(self.predict)
139
+
140
+ # Save results
141
+ df.to_csv(output_path, index=False, encoding='utf-8-sig')
142
+ print(f"Results saved to {output_path}")
143
+
144
+ return df
145
+
146
+ except Exception as e:
147
+ print(f"Error: {str(e)}")
148
+ return None
149
+
150
+
151
+ # Github : RezaGooner
@@ -1,4 +1,4 @@
1
1
  from .CommentAnalyzer import CommentAnalyzer
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.2"
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.2
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.2",
9
9
  author="RezaGooner",
10
10
  author_email="RezaAsadiProgrammer@Gmail.com",
11
11
  description="Persian Sentiment Analysis Toolkit",
File without changes
File without changes