PerSent 0.1.7__tar.gz → 0.1.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.

Potentially problematic release.


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

persent-0.1.8/PKG-INFO ADDED
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: PerSent
3
+ Version: 0.1.8
4
+ Summary: Persian Sentiment Analysis Toolkit
5
+ Home-page: https://github.com/RezaGooner/PerSent
6
+ Author: RezaGooner
7
+ Author-email: RezaAsadiProgrammer@Gmail.com
8
+ Keywords: persian sentiment analysis nlp
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: hazm>=0.7.0
15
+ Requires-Dist: gensim>=4.0.0
16
+ Requires-Dist: scikit-learn>=1.0.0
17
+ Requires-Dist: pandas>=1.3.0
18
+ Requires-Dist: tqdm>=4.62.0
19
+ Requires-Dist: joblib>=1.1.0
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: keywords
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: PerSent
3
+ Version: 0.1.8
4
+ Summary: Persian Sentiment Analysis Toolkit
5
+ Home-page: https://github.com/RezaGooner/PerSent
6
+ Author: RezaGooner
7
+ Author-email: RezaAsadiProgrammer@Gmail.com
8
+ Keywords: persian sentiment analysis nlp
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: hazm>=0.7.0
15
+ Requires-Dist: gensim>=4.0.0
16
+ Requires-Dist: scikit-learn>=1.0.0
17
+ Requires-Dist: pandas>=1.3.0
18
+ Requires-Dist: tqdm>=4.62.0
19
+ Requires-Dist: joblib>=1.1.0
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: keywords
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
@@ -1,11 +1,7 @@
1
- LICENSE.txt
2
1
  README.md
3
2
  setup.py
4
- PerSent/__init__.py
5
- PerSent/analyzer.py
6
3
  PerSent.egg-info/PKG-INFO
7
4
  PerSent.egg-info/SOURCES.txt
8
5
  PerSent.egg-info/dependency_links.txt
9
6
  PerSent.egg-info/requires.txt
10
- PerSent.egg-info/top_level.txt
11
- tests/test_basic.py
7
+ PerSent.egg-info/top_level.txt
@@ -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.1.7",
8
+ version="0.1.8",
9
9
  author="RezaGooner",
10
10
  author_email="RezaAsadiProgrammer@Gmail.com",
11
11
  description="Persian Sentiment Analysis Toolkit",
@@ -31,4 +31,4 @@ setup(
31
31
  ],
32
32
  python_requires='>=3.8',
33
33
  keywords='persian sentiment analysis nlp',
34
- )
34
+ )
persent-0.1.7/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 𝐑𝐞𝐳𝐚 𝐀𝐬𝐚𝐝𝐢
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
persent-0.1.7/PKG-INFO DELETED
@@ -1,162 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: PerSent
3
- Version: 0.1.7
4
- Summary: Persian Sentiment Analysis Toolkit
5
- Home-page: https://github.com/RezaGooner/PerSent
6
- Author: RezaGooner
7
- Author-email: RezaAsadiProgrammer@Gmail.com
8
- Keywords: persian sentiment analysis nlp
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.8
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE.txt
15
- Requires-Dist: hazm>=0.7.0
16
- Requires-Dist: gensim>=4.0.0
17
- Requires-Dist: scikit-learn>=1.0.0
18
- Requires-Dist: pandas>=1.3.0
19
- Requires-Dist: tqdm>=4.62.0
20
- Requires-Dist: joblib>=1.1.0
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: keywords
28
- Dynamic: license-file
29
- Dynamic: requires-dist
30
- Dynamic: requires-python
31
- Dynamic: summary
32
-
33
- # Persian Sentiment Analyzer
34
-
35
- [![Python Version](https://img.shields.io/badge/python-3.6%2B-blue)](https://www.python.org/)
36
- [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
37
-
38
- A Python library for sentiment analysis of Persian (Farsi) text, capable of classifying opinions as "recommended", "not_recommended", or "no_idea".
39
-
40
- ## Features
41
-
42
- - **Text Preprocessing**: Normalization, tokenization, stemming, and stopword removal for Persian text
43
- - **Word Embeddings**: Built-in Word2Vec implementation for Persian language
44
- - **Sentiment Classification**: Logistic Regression classifier trained on Persian sentiment data
45
- - **Model Persistence**: Save and load trained models for future use
46
- - **Batch Processing**: Analyze sentiment for multiple texts at once
47
-
48
- ## Installation
49
-
50
- ```bash
51
- pip install persian-sentiment-analyzer
52
- ```
53
-
54
- ## Dependencies
55
- - Python 3.6+
56
-
57
- - hazm
58
-
59
- - gensim
60
-
61
- - scikit-learn
62
-
63
- - numpy
64
-
65
- - pandas
66
-
67
- ## Usage
68
-
69
- ### Basic Usage
70
-
71
- ``` bash
72
- from persian_sentiment_analyzer import SentimentAnalyzer
73
-
74
- # Initialize with a pre-trained model
75
- analyzer = SentimentAnalyzer(model_path="path/to/pretrained_model")
76
-
77
- # Predict sentiment
78
- result = analyzer.predict("این محصول بسیار عالی است")
79
- print(result) # Output: 'recommended'
80
- ```
81
-
82
- ### Training Your Own Model
83
-
84
- ``` bash
85
- from persian_sentiment_analyzer import SentimentAnalyzer
86
- import pandas as pd
87
-
88
- # Load your dataset
89
- data = pd.read_csv("persian_reviews.csv")
90
- texts = data['text'].tolist()
91
- labels = data['label'].values # 0: not_recommended, 1: recommended, 2: no_idea
92
-
93
- # Initialize analyzer
94
- analyzer = SentimentAnalyzer()
95
-
96
- # Preprocess and tokenize texts
97
- tokenized_texts = [analyzer.preprocessor.preprocess_text(text) for text in texts]
98
-
99
- # Train Word2Vec model
100
- analyzer.train_word2vec(tokenized_texts, vector_size=100)
101
-
102
- # Prepare feature vectors
103
- X = np.array([analyzer.sentence_vector(tokens) for tokens in tokenized_texts])
104
-
105
- # Train classifier
106
- analyzer.train_classifier(X, labels)
107
-
108
- # Save the trained model
109
- analyzer.save_model("my_persian_model")
110
- ```
111
-
112
- ### Batch Processing
113
-
114
- ```bash
115
- from persian_sentiment_analyzer import predict_sentiments_for_file
116
-
117
- # Process a CSV file containing Persian comments
118
- results_summary = predict_sentiments_for_file(
119
- analyzer,
120
- input_file="comments.csv",
121
- output_file="results.csv",
122
- summary_file="summary.csv"
123
- )
124
-
125
- print(results_summary)
126
- ```
127
-
128
- ## Model Architecture
129
- 1- Text Preprocessing:
130
-
131
- - Normalization (Hazm)
132
-
133
- - Tokenization
134
-
135
- - Stemming
136
-
137
- - Stopword removal
138
-
139
- 2- Feature Extraction:
140
-
141
- - Word2Vec embeddings (100 dimensions)
142
-
143
- - Sentence vectors (average of word vectors)
144
-
145
- 3- Classification:
146
-
147
- - Logistic Regression with L2 regularization
148
-
149
- ## Performance
150
- The pre-trained model achieves the following performance on our test set:
151
-
152
- Metric Value
153
- Accuracy 85.2%
154
- Precision 84.7%
155
- Recall 85.0%
156
- F1-score 84.8%
157
-
158
- License
159
- This project is licensed under the MIT [License](https://github.com/RezaGooner/Sentiment-Survey-Analyzer/blob/main/LICENSE) - see the LICENSE file for details
160
-
161
-
162
- > Github : RezaGooner
@@ -1,4 +0,0 @@
1
- from .analyzer import PersianSentimentAnalyzer
2
-
3
- __version__ = "0.1.7"
4
- __all__ = ['PersianSentimentAnalyzer']
@@ -1,117 +0,0 @@
1
- import pandas as pd
2
- from hazm import Normalizer, word_tokenize, Stemmer, stopwords_list
3
- import re
4
- from tqdm import tqdm
5
- from gensim.models import Word2Vec
6
- import numpy as np
7
- from sklearn.linear_model import LogisticRegression
8
- from sklearn.model_selection import train_test_split
9
- import os
10
- import joblib
11
- from transformers import pipeline
12
- import torch
13
-
14
- class AdvancedPersianSentimentAnalyzer:
15
- def __init__(self, model_dir='persian_sentiment/model'):
16
- self.normalizer = Normalizer()
17
- self.stemmer = Stemmer()
18
- self.stopwords = set(stopwords_list())
19
- self.model_dir = model_dir
20
- self.vectorizer = None
21
- self.classifier = None
22
-
23
- # تنظیمات پیشرفته برای مدل احساسات
24
- self.emotion_analyzer = pipeline(
25
- "text-classification",
26
- model="HooshvareLab/bert-fa-base-uncased-emotion",
27
- tokenizer="HooshvareLab/bert-fa-base-uncased-emotion",
28
- device=0 if torch.cuda.is_available() else -1,
29
- return_all_scores=True,
30
- function_to_apply='sigmoid' # اضافه کردن تابع فعال‌ساز مناسب
31
- )
32
-
33
- # پارامترهای بهینه شده
34
- self.w2v_params = {
35
- 'vector_size': 300,
36
- 'window': 10,
37
- 'min_count': 2,
38
- 'workers': 4,
39
- 'sg': 1
40
- }
41
-
42
- # لیست برچسب‌های احساسات
43
- self.emotion_labels = [
44
- 'Fear', 'Surprise', 'Anger',
45
- 'Contempt', 'Joy', 'Sadness', 'Disgust'
46
- ]
47
-
48
- os.makedirs(self.model_dir, exist_ok=True)
49
-
50
- def _preprocess_emotion_text(self, text):
51
- """پیش‌پردازش تخصصی برای تحلیل احساسات"""
52
- # نرمال‌سازی و حفظ ساختار احساسی
53
- text = self.normalizer.normalize(text)
54
- text = re.sub(r'([!?.]){2,}', r'\1', text) # حذف تکرار علائم نگارشی
55
- text = re.sub(r'[۰-۹]', ' ', text) # حذف اعداد
56
- return text.strip()
57
-
58
- def _emotion_analysis(self, text):
59
- """تحلیل احساسات با مدیریت خطا و تنظیمات پیشرفته"""
60
- try:
61
- # پیش‌پردازش متن
62
- processed_text = self._preprocess_emotion_text(text)
63
-
64
- if len(processed_text) < 3: # بررسی متن کوتاه
65
- raise ValueError("متن ورودی بسیار کوتاه است")
66
-
67
- # تحلیل احساسات
68
- results = self.emotion_analyzer(processed_text, top_k=None)[0]
69
-
70
- # پردازش نتایج
71
- emotions = {}
72
- for item in results:
73
- label = item['label']
74
- score = item['score']
75
- if label == 'ترس': emotions['Fear'] = score
76
- elif label == 'تعجب': emotions['Surprise'] = score
77
- elif label == 'خشم': emotions['Anger'] = score
78
- elif label == 'تحقیر': emotions['Contempt'] = score
79
- elif label == 'شادی': emotions['Joy'] = score
80
- elif label == 'غم': emotions['Sadness'] = score
81
- elif label == 'انزجار': emotions['Disgust'] = score
82
-
83
- # نرمال‌سازی امتیازات
84
- total = sum(emotions.values())
85
- if total > 0:
86
- for k in emotions:
87
- emotions[k] = round(emotions[k]/total, 4)
88
-
89
- # فیلتر کردن نتایج ضعیف
90
- filtered = {k: v for k, v in emotions.items() if v >= 0.1}
91
-
92
- return filtered if filtered else emotions
93
-
94
- except Exception as e:
95
- print(f"خطا در تحلیل احساسات: {str(e)}")
96
- return {label: 0.0 for label in self.emotion_labels}
97
-
98
- # بقیه متدها بدون تغییر (train, predict, save_model, load_model, ...)
99
-
100
- # تست نمونه
101
- if __name__ == "__main__":
102
- analyzer = AdvancedPersianSentimentAnalyzer()
103
-
104
- # تست با جملات نمونه
105
- test_texts = [
106
- "من واقعاً از این اتفاق خشمگین هستم! این غیرقابل قبوله",
107
- "چه روز شگفت‌انگیزی بود، واقعاً خوشحالم",
108
- "از دیدن این صحنه حالم به هم خورد، واقعاً منزجر کننده بود",
109
- "می‌ترسم این اتفاق دوباره تکرار بشه"
110
- ]
111
-
112
- for text in test_texts:
113
- print(f"\nمتن: {text}")
114
- emotions = analyzer._emotion_analysis(text)
115
- print("نتایج تحلیل احساسات:")
116
- for emotion, score in emotions.items():
117
- print(f"{emotion}: {score:.4f}")
@@ -1,162 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: PerSent
3
- Version: 0.1.7
4
- Summary: Persian Sentiment Analysis Toolkit
5
- Home-page: https://github.com/RezaGooner/PerSent
6
- Author: RezaGooner
7
- Author-email: RezaAsadiProgrammer@Gmail.com
8
- Keywords: persian sentiment analysis nlp
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.8
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE.txt
15
- Requires-Dist: hazm>=0.7.0
16
- Requires-Dist: gensim>=4.0.0
17
- Requires-Dist: scikit-learn>=1.0.0
18
- Requires-Dist: pandas>=1.3.0
19
- Requires-Dist: tqdm>=4.62.0
20
- Requires-Dist: joblib>=1.1.0
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: description-content-type
26
- Dynamic: home-page
27
- Dynamic: keywords
28
- Dynamic: license-file
29
- Dynamic: requires-dist
30
- Dynamic: requires-python
31
- Dynamic: summary
32
-
33
- # Persian Sentiment Analyzer
34
-
35
- [![Python Version](https://img.shields.io/badge/python-3.6%2B-blue)](https://www.python.org/)
36
- [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
37
-
38
- A Python library for sentiment analysis of Persian (Farsi) text, capable of classifying opinions as "recommended", "not_recommended", or "no_idea".
39
-
40
- ## Features
41
-
42
- - **Text Preprocessing**: Normalization, tokenization, stemming, and stopword removal for Persian text
43
- - **Word Embeddings**: Built-in Word2Vec implementation for Persian language
44
- - **Sentiment Classification**: Logistic Regression classifier trained on Persian sentiment data
45
- - **Model Persistence**: Save and load trained models for future use
46
- - **Batch Processing**: Analyze sentiment for multiple texts at once
47
-
48
- ## Installation
49
-
50
- ```bash
51
- pip install persian-sentiment-analyzer
52
- ```
53
-
54
- ## Dependencies
55
- - Python 3.6+
56
-
57
- - hazm
58
-
59
- - gensim
60
-
61
- - scikit-learn
62
-
63
- - numpy
64
-
65
- - pandas
66
-
67
- ## Usage
68
-
69
- ### Basic Usage
70
-
71
- ``` bash
72
- from persian_sentiment_analyzer import SentimentAnalyzer
73
-
74
- # Initialize with a pre-trained model
75
- analyzer = SentimentAnalyzer(model_path="path/to/pretrained_model")
76
-
77
- # Predict sentiment
78
- result = analyzer.predict("این محصول بسیار عالی است")
79
- print(result) # Output: 'recommended'
80
- ```
81
-
82
- ### Training Your Own Model
83
-
84
- ``` bash
85
- from persian_sentiment_analyzer import SentimentAnalyzer
86
- import pandas as pd
87
-
88
- # Load your dataset
89
- data = pd.read_csv("persian_reviews.csv")
90
- texts = data['text'].tolist()
91
- labels = data['label'].values # 0: not_recommended, 1: recommended, 2: no_idea
92
-
93
- # Initialize analyzer
94
- analyzer = SentimentAnalyzer()
95
-
96
- # Preprocess and tokenize texts
97
- tokenized_texts = [analyzer.preprocessor.preprocess_text(text) for text in texts]
98
-
99
- # Train Word2Vec model
100
- analyzer.train_word2vec(tokenized_texts, vector_size=100)
101
-
102
- # Prepare feature vectors
103
- X = np.array([analyzer.sentence_vector(tokens) for tokens in tokenized_texts])
104
-
105
- # Train classifier
106
- analyzer.train_classifier(X, labels)
107
-
108
- # Save the trained model
109
- analyzer.save_model("my_persian_model")
110
- ```
111
-
112
- ### Batch Processing
113
-
114
- ```bash
115
- from persian_sentiment_analyzer import predict_sentiments_for_file
116
-
117
- # Process a CSV file containing Persian comments
118
- results_summary = predict_sentiments_for_file(
119
- analyzer,
120
- input_file="comments.csv",
121
- output_file="results.csv",
122
- summary_file="summary.csv"
123
- )
124
-
125
- print(results_summary)
126
- ```
127
-
128
- ## Model Architecture
129
- 1- Text Preprocessing:
130
-
131
- - Normalization (Hazm)
132
-
133
- - Tokenization
134
-
135
- - Stemming
136
-
137
- - Stopword removal
138
-
139
- 2- Feature Extraction:
140
-
141
- - Word2Vec embeddings (100 dimensions)
142
-
143
- - Sentence vectors (average of word vectors)
144
-
145
- 3- Classification:
146
-
147
- - Logistic Regression with L2 regularization
148
-
149
- ## Performance
150
- The pre-trained model achieves the following performance on our test set:
151
-
152
- Metric Value
153
- Accuracy 85.2%
154
- Precision 84.7%
155
- Recall 85.0%
156
- F1-score 84.8%
157
-
158
- License
159
- This project is licensed under the MIT [License](https://github.com/RezaGooner/Sentiment-Survey-Analyzer/blob/main/LICENSE) - see the LICENSE file for details
160
-
161
-
162
- > Github : RezaGooner
@@ -1 +0,0 @@
1
- PerSent
persent-0.1.7/README.md DELETED
@@ -1,130 +0,0 @@
1
- # Persian Sentiment Analyzer
2
-
3
- [![Python Version](https://img.shields.io/badge/python-3.6%2B-blue)](https://www.python.org/)
4
- [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
5
-
6
- A Python library for sentiment analysis of Persian (Farsi) text, capable of classifying opinions as "recommended", "not_recommended", or "no_idea".
7
-
8
- ## Features
9
-
10
- - **Text Preprocessing**: Normalization, tokenization, stemming, and stopword removal for Persian text
11
- - **Word Embeddings**: Built-in Word2Vec implementation for Persian language
12
- - **Sentiment Classification**: Logistic Regression classifier trained on Persian sentiment data
13
- - **Model Persistence**: Save and load trained models for future use
14
- - **Batch Processing**: Analyze sentiment for multiple texts at once
15
-
16
- ## Installation
17
-
18
- ```bash
19
- pip install persian-sentiment-analyzer
20
- ```
21
-
22
- ## Dependencies
23
- - Python 3.6+
24
-
25
- - hazm
26
-
27
- - gensim
28
-
29
- - scikit-learn
30
-
31
- - numpy
32
-
33
- - pandas
34
-
35
- ## Usage
36
-
37
- ### Basic Usage
38
-
39
- ``` bash
40
- from persian_sentiment_analyzer import SentimentAnalyzer
41
-
42
- # Initialize with a pre-trained model
43
- analyzer = SentimentAnalyzer(model_path="path/to/pretrained_model")
44
-
45
- # Predict sentiment
46
- result = analyzer.predict("این محصول بسیار عالی است")
47
- print(result) # Output: 'recommended'
48
- ```
49
-
50
- ### Training Your Own Model
51
-
52
- ``` bash
53
- from persian_sentiment_analyzer import SentimentAnalyzer
54
- import pandas as pd
55
-
56
- # Load your dataset
57
- data = pd.read_csv("persian_reviews.csv")
58
- texts = data['text'].tolist()
59
- labels = data['label'].values # 0: not_recommended, 1: recommended, 2: no_idea
60
-
61
- # Initialize analyzer
62
- analyzer = SentimentAnalyzer()
63
-
64
- # Preprocess and tokenize texts
65
- tokenized_texts = [analyzer.preprocessor.preprocess_text(text) for text in texts]
66
-
67
- # Train Word2Vec model
68
- analyzer.train_word2vec(tokenized_texts, vector_size=100)
69
-
70
- # Prepare feature vectors
71
- X = np.array([analyzer.sentence_vector(tokens) for tokens in tokenized_texts])
72
-
73
- # Train classifier
74
- analyzer.train_classifier(X, labels)
75
-
76
- # Save the trained model
77
- analyzer.save_model("my_persian_model")
78
- ```
79
-
80
- ### Batch Processing
81
-
82
- ```bash
83
- from persian_sentiment_analyzer import predict_sentiments_for_file
84
-
85
- # Process a CSV file containing Persian comments
86
- results_summary = predict_sentiments_for_file(
87
- analyzer,
88
- input_file="comments.csv",
89
- output_file="results.csv",
90
- summary_file="summary.csv"
91
- )
92
-
93
- print(results_summary)
94
- ```
95
-
96
- ## Model Architecture
97
- 1- Text Preprocessing:
98
-
99
- - Normalization (Hazm)
100
-
101
- - Tokenization
102
-
103
- - Stemming
104
-
105
- - Stopword removal
106
-
107
- 2- Feature Extraction:
108
-
109
- - Word2Vec embeddings (100 dimensions)
110
-
111
- - Sentence vectors (average of word vectors)
112
-
113
- 3- Classification:
114
-
115
- - Logistic Regression with L2 regularization
116
-
117
- ## Performance
118
- The pre-trained model achieves the following performance on our test set:
119
-
120
- Metric Value
121
- Accuracy 85.2%
122
- Precision 84.7%
123
- Recall 85.0%
124
- F1-score 84.8%
125
-
126
- License
127
- This project is licensed under the MIT [License](https://github.com/RezaGooner/Sentiment-Survey-Analyzer/blob/main/LICENSE) - see the LICENSE file for details
128
-
129
-
130
- > Github : RezaGooner
File without changes