sentix 1.0.0__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.
Files changed (37) hide show
  1. sentix-1.0.0/LICENSE +21 -0
  2. sentix-1.0.0/PKG-INFO +342 -0
  3. sentix-1.0.0/README.md +314 -0
  4. sentix-1.0.0/pyproject.toml +83 -0
  5. sentix-1.0.0/setup.cfg +4 -0
  6. sentix-1.0.0/src/sentix/__init__.py +18 -0
  7. sentix-1.0.0/src/sentix/analyzer.py +224 -0
  8. sentix-1.0.0/src/sentix/certainty.py +45 -0
  9. sentix-1.0.0/src/sentix/confidence.py +53 -0
  10. sentix-1.0.0/src/sentix/explanation.py +404 -0
  11. sentix-1.0.0/src/sentix/lexicon/__init__.py +0 -0
  12. sentix-1.0.0/src/sentix/lexicon/aspects.py +7 -0
  13. sentix-1.0.0/src/sentix/lexicon/emoji.py +24 -0
  14. sentix-1.0.0/src/sentix/lexicon/emotion.py +36 -0
  15. sentix-1.0.0/src/sentix/lexicon/phrases.py +9 -0
  16. sentix-1.0.0/src/sentix/lexicon/sentiment.py +60 -0
  17. sentix-1.0.0/src/sentix/normalize.py +234 -0
  18. sentix-1.0.0/src/sentix/result.py +103 -0
  19. sentix-1.0.0/src/sentix/rules/aspect.py +99 -0
  20. sentix-1.0.0/src/sentix/rules/conditional.py +411 -0
  21. sentix-1.0.0/src/sentix/rules/context.py +249 -0
  22. sentix-1.0.0/src/sentix/rules/contradiction.py +587 -0
  23. sentix-1.0.0/src/sentix/rules/contrast.py +1081 -0
  24. sentix-1.0.0/src/sentix/rules/emotion.py +31 -0
  25. sentix-1.0.0/src/sentix/rules/intensity.py +31 -0
  26. sentix-1.0.0/src/sentix/rules/negation.py +274 -0
  27. sentix-1.0.0/src/sentix/rules/normalize.py +5 -0
  28. sentix-1.0.0/src/sentix/rules/phrases.py +30 -0
  29. sentix-1.0.0/src/sentix/rules/repetition.py +16 -0
  30. sentix-1.0.0/src/sentix/rules/reversal.py +312 -0
  31. sentix-1.0.0/src/sentix/scorer.py +542 -0
  32. sentix-1.0.0/src/sentix/tokenizer.py +16 -0
  33. sentix-1.0.0/src/sentix.egg-info/PKG-INFO +342 -0
  34. sentix-1.0.0/src/sentix.egg-info/SOURCES.txt +35 -0
  35. sentix-1.0.0/src/sentix.egg-info/dependency_links.txt +1 -0
  36. sentix-1.0.0/src/sentix.egg-info/top_level.txt +1 -0
  37. sentix-1.0.0/tests/test_sentiment.py +2102 -0
sentix-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sentix Contributors
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.
sentix-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.4
2
+ Name: sentix
3
+ Version: 1.0.0
4
+ Summary: A lightweight and explainable rule-based sentiment analysis library for Python
5
+ Author: Abdul Fathah
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/fathaah910/sentix
8
+ Project-URL: Repository, https://github.com/fathaah910/sentix
9
+ Project-URL: Issues, https://github.com/fathaah910/sentix/issues
10
+ Keywords: sentiment-analysis,nlp,natural-language-processing,sentiment,text-analysis,emotion-analysis,python
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Text Processing
23
+ Classifier: Topic :: Text Processing :: Linguistic
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # Sentix
30
+
31
+ A lightweight and explainable rule-based sentiment analysis library for Python.
32
+
33
+ Sentix provides sentiment classification with support for:
34
+
35
+ - Positive sentiment
36
+ - Negative sentiment
37
+ - Neutral sentiment
38
+ - Mixed sentiment
39
+ - Negation handling
40
+ - Intensity modifiers
41
+ - Diminishers
42
+ - Contrast detection
43
+ - Aspect-based sentiment
44
+ - Emotion detection
45
+ - Confidence scoring
46
+ - Evidence-based explanations
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install sentix
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ```python
57
+ from sentix import SentimentAnalyzer
58
+
59
+ analyzer = SentimentAnalyzer()
60
+
61
+ result = analyzer.predict(
62
+ "I love the camera, but I hate the battery."
63
+ )
64
+
65
+ print(result.label)
66
+ print(result.score)
67
+ print(result.confidence)
68
+ ```
69
+
70
+ Example output:
71
+
72
+ ```text
73
+ mixed
74
+ 0.0
75
+ 0.49
76
+ ```
77
+
78
+ ## Full Result
79
+
80
+ ```python
81
+ from sentix import SentimentAnalyzer
82
+
83
+ analyzer = SentimentAnalyzer()
84
+
85
+ result = analyzer.predict(
86
+ "The camera is amazing, but the battery is terrible."
87
+ )
88
+
89
+ print(result.to_dict())
90
+ ```
91
+
92
+ Example structure:
93
+
94
+ ```python
95
+ {
96
+ "label": "mixed",
97
+ "score": 0.0,
98
+ "positive": 0.5,
99
+ "negative": 0.5,
100
+ "neutral": 0.0,
101
+ "confidence": 0.49,
102
+ "emotions": {},
103
+ "aspects": {},
104
+ "evidence": []
105
+ }
106
+ ```
107
+
108
+ ## Supported Sentiment Labels
109
+
110
+ Sentix can return four sentiment labels:
111
+
112
+ | Label | Meaning |
113
+ |---|---|
114
+ | `positive` | Overall positive sentiment |
115
+ | `negative` | Overall negative sentiment |
116
+ | `neutral` | No significant sentiment detected |
117
+ | `mixed` | Both positive and negative sentiment detected |
118
+
119
+ ## Negation
120
+
121
+ Sentix handles common negation patterns.
122
+
123
+ ```python
124
+ analyzer.predict("I don't like this.")
125
+ ```
126
+
127
+ Expected sentiment:
128
+
129
+ ```text
130
+ negative
131
+ ```
132
+
133
+ Example:
134
+
135
+ ```python
136
+ analyzer.predict("I don't think this is good.")
137
+ ```
138
+
139
+ Expected sentiment:
140
+
141
+ ```text
142
+ negative
143
+ ```
144
+
145
+ ## Intensity
146
+
147
+ Sentix supports intensity modifiers.
148
+
149
+ ```python
150
+ analyzer.predict(
151
+ "This is extremely amazing."
152
+ )
153
+ ```
154
+
155
+ The word `extremely` increases the strength of the sentiment.
156
+
157
+ ## Diminishers
158
+
159
+ Sentix also supports diminishing modifiers.
160
+
161
+ ```python
162
+ analyzer.predict(
163
+ "The battery is slightly bad."
164
+ )
165
+ ```
166
+
167
+ The negative sentiment is weaker than:
168
+
169
+ ```python
170
+ "The battery is terrible."
171
+ ```
172
+
173
+ ## Contrast Handling
174
+
175
+ Sentix analyzes contrast expressions such as `but`.
176
+
177
+ ```python
178
+ analyzer.predict(
179
+ "I love this, but the battery is terrible."
180
+ )
181
+ ```
182
+
183
+ Contrast analysis considers sentiment before and after the contrast marker.
184
+
185
+ ## Mixed Sentiment
186
+
187
+ Sentix can detect conflicting sentiment.
188
+
189
+ ```python
190
+ analyzer.predict(
191
+ "I love the screen, but I hate the battery."
192
+ )
193
+ ```
194
+
195
+ Possible output:
196
+
197
+ ```text
198
+ mixed
199
+ ```
200
+
201
+ ## Aspect-Based Sentiment
202
+
203
+ Sentix can identify sentiment associated with specific aspects.
204
+
205
+ ```python
206
+ result = analyzer.predict(
207
+ "The camera is amazing but the battery is terrible."
208
+ )
209
+
210
+ print(result.aspects)
211
+ ```
212
+
213
+ Example:
214
+
215
+ ```python
216
+ {
217
+ "camera": {
218
+ "sentiment": "positive",
219
+ "score": 2.0
220
+ },
221
+ "battery": {
222
+ "sentiment": "negative",
223
+ "score": -2.0
224
+ }
225
+ }
226
+ ```
227
+
228
+ ## Emotion Detection
229
+
230
+ Sentix can detect emotion-related signals.
231
+
232
+ ```python
233
+ result = analyzer.predict(
234
+ "I am extremely happy and excited."
235
+ )
236
+
237
+ print(result.emotions)
238
+ ```
239
+
240
+ ## Evidence
241
+
242
+ Sentix provides explainable sentiment evidence.
243
+
244
+ ```python
245
+ result = analyzer.predict(
246
+ "This product is extremely amazing!"
247
+ )
248
+
249
+ for item in result.evidence:
250
+ print(item)
251
+ ```
252
+
253
+ Evidence may include:
254
+
255
+ - sentiment word
256
+ - base score
257
+ - intensity modifier
258
+ - negation modifier
259
+ - capitalization modifier
260
+ - final score
261
+
262
+ ## Benchmark
263
+
264
+ Current benchmark results on the Sentix benchmark dataset:
265
+
266
+ | Library | Accuracy | Macro F1 |
267
+ |---|---:|---:|
268
+ | **Sentix** | **97%** | **0.9632** |
269
+ | VADER | 83% | 0.6793 |
270
+ | TextBlob | 69% | 0.5264 |
271
+
272
+ ### Category Performance
273
+
274
+ | Category | Sentix |
275
+ |---|---:|
276
+ | Basic | 100% |
277
+ | Negation | 100% |
278
+ | Intensity | 100% |
279
+ | Diminisher | 100% |
280
+ | Contrast | 80% |
281
+ | Mixed | 90% |
282
+ | Aspect | 100% |
283
+ | Morphology | 100% |
284
+ | Emphasis | 100% |
285
+ | Neutral | 100% |
286
+
287
+ ## Testing
288
+
289
+ Run the complete test suite:
290
+
291
+ ```bash
292
+ python -m pytest
293
+ ```
294
+
295
+ Current status:
296
+
297
+ ```text
298
+ 173 passed
299
+ ```
300
+
301
+ ## Benchmark
302
+
303
+ Run:
304
+
305
+ ```bash
306
+ python benchmarks/benchmark_sentiment.py
307
+ ```
308
+
309
+ ## Performance
310
+
311
+ On the current benchmark dataset of 100 samples:
312
+
313
+ ```text
314
+ Sentix: approximately 0.036 seconds
315
+ ```
316
+
317
+ This is approximately:
318
+
319
+ ```text
320
+ 0.36 milliseconds per sample
321
+ ```
322
+
323
+ Performance will vary depending on hardware and Python version.
324
+
325
+ ## Design Philosophy
326
+
327
+ Sentix focuses on:
328
+
329
+ - Lightweight implementation
330
+ - Explainability
331
+ - Rule-based reasoning
332
+ - No external machine learning model requirement
333
+ - Fast inference
334
+ - Transparent sentiment evidence
335
+
336
+ ## License
337
+
338
+ MIT License
339
+
340
+ ## Author
341
+
342
+ Sentix Contributors
sentix-1.0.0/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # Sentix
2
+
3
+ A lightweight and explainable rule-based sentiment analysis library for Python.
4
+
5
+ Sentix provides sentiment classification with support for:
6
+
7
+ - Positive sentiment
8
+ - Negative sentiment
9
+ - Neutral sentiment
10
+ - Mixed sentiment
11
+ - Negation handling
12
+ - Intensity modifiers
13
+ - Diminishers
14
+ - Contrast detection
15
+ - Aspect-based sentiment
16
+ - Emotion detection
17
+ - Confidence scoring
18
+ - Evidence-based explanations
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install sentix
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```python
29
+ from sentix import SentimentAnalyzer
30
+
31
+ analyzer = SentimentAnalyzer()
32
+
33
+ result = analyzer.predict(
34
+ "I love the camera, but I hate the battery."
35
+ )
36
+
37
+ print(result.label)
38
+ print(result.score)
39
+ print(result.confidence)
40
+ ```
41
+
42
+ Example output:
43
+
44
+ ```text
45
+ mixed
46
+ 0.0
47
+ 0.49
48
+ ```
49
+
50
+ ## Full Result
51
+
52
+ ```python
53
+ from sentix import SentimentAnalyzer
54
+
55
+ analyzer = SentimentAnalyzer()
56
+
57
+ result = analyzer.predict(
58
+ "The camera is amazing, but the battery is terrible."
59
+ )
60
+
61
+ print(result.to_dict())
62
+ ```
63
+
64
+ Example structure:
65
+
66
+ ```python
67
+ {
68
+ "label": "mixed",
69
+ "score": 0.0,
70
+ "positive": 0.5,
71
+ "negative": 0.5,
72
+ "neutral": 0.0,
73
+ "confidence": 0.49,
74
+ "emotions": {},
75
+ "aspects": {},
76
+ "evidence": []
77
+ }
78
+ ```
79
+
80
+ ## Supported Sentiment Labels
81
+
82
+ Sentix can return four sentiment labels:
83
+
84
+ | Label | Meaning |
85
+ |---|---|
86
+ | `positive` | Overall positive sentiment |
87
+ | `negative` | Overall negative sentiment |
88
+ | `neutral` | No significant sentiment detected |
89
+ | `mixed` | Both positive and negative sentiment detected |
90
+
91
+ ## Negation
92
+
93
+ Sentix handles common negation patterns.
94
+
95
+ ```python
96
+ analyzer.predict("I don't like this.")
97
+ ```
98
+
99
+ Expected sentiment:
100
+
101
+ ```text
102
+ negative
103
+ ```
104
+
105
+ Example:
106
+
107
+ ```python
108
+ analyzer.predict("I don't think this is good.")
109
+ ```
110
+
111
+ Expected sentiment:
112
+
113
+ ```text
114
+ negative
115
+ ```
116
+
117
+ ## Intensity
118
+
119
+ Sentix supports intensity modifiers.
120
+
121
+ ```python
122
+ analyzer.predict(
123
+ "This is extremely amazing."
124
+ )
125
+ ```
126
+
127
+ The word `extremely` increases the strength of the sentiment.
128
+
129
+ ## Diminishers
130
+
131
+ Sentix also supports diminishing modifiers.
132
+
133
+ ```python
134
+ analyzer.predict(
135
+ "The battery is slightly bad."
136
+ )
137
+ ```
138
+
139
+ The negative sentiment is weaker than:
140
+
141
+ ```python
142
+ "The battery is terrible."
143
+ ```
144
+
145
+ ## Contrast Handling
146
+
147
+ Sentix analyzes contrast expressions such as `but`.
148
+
149
+ ```python
150
+ analyzer.predict(
151
+ "I love this, but the battery is terrible."
152
+ )
153
+ ```
154
+
155
+ Contrast analysis considers sentiment before and after the contrast marker.
156
+
157
+ ## Mixed Sentiment
158
+
159
+ Sentix can detect conflicting sentiment.
160
+
161
+ ```python
162
+ analyzer.predict(
163
+ "I love the screen, but I hate the battery."
164
+ )
165
+ ```
166
+
167
+ Possible output:
168
+
169
+ ```text
170
+ mixed
171
+ ```
172
+
173
+ ## Aspect-Based Sentiment
174
+
175
+ Sentix can identify sentiment associated with specific aspects.
176
+
177
+ ```python
178
+ result = analyzer.predict(
179
+ "The camera is amazing but the battery is terrible."
180
+ )
181
+
182
+ print(result.aspects)
183
+ ```
184
+
185
+ Example:
186
+
187
+ ```python
188
+ {
189
+ "camera": {
190
+ "sentiment": "positive",
191
+ "score": 2.0
192
+ },
193
+ "battery": {
194
+ "sentiment": "negative",
195
+ "score": -2.0
196
+ }
197
+ }
198
+ ```
199
+
200
+ ## Emotion Detection
201
+
202
+ Sentix can detect emotion-related signals.
203
+
204
+ ```python
205
+ result = analyzer.predict(
206
+ "I am extremely happy and excited."
207
+ )
208
+
209
+ print(result.emotions)
210
+ ```
211
+
212
+ ## Evidence
213
+
214
+ Sentix provides explainable sentiment evidence.
215
+
216
+ ```python
217
+ result = analyzer.predict(
218
+ "This product is extremely amazing!"
219
+ )
220
+
221
+ for item in result.evidence:
222
+ print(item)
223
+ ```
224
+
225
+ Evidence may include:
226
+
227
+ - sentiment word
228
+ - base score
229
+ - intensity modifier
230
+ - negation modifier
231
+ - capitalization modifier
232
+ - final score
233
+
234
+ ## Benchmark
235
+
236
+ Current benchmark results on the Sentix benchmark dataset:
237
+
238
+ | Library | Accuracy | Macro F1 |
239
+ |---|---:|---:|
240
+ | **Sentix** | **97%** | **0.9632** |
241
+ | VADER | 83% | 0.6793 |
242
+ | TextBlob | 69% | 0.5264 |
243
+
244
+ ### Category Performance
245
+
246
+ | Category | Sentix |
247
+ |---|---:|
248
+ | Basic | 100% |
249
+ | Negation | 100% |
250
+ | Intensity | 100% |
251
+ | Diminisher | 100% |
252
+ | Contrast | 80% |
253
+ | Mixed | 90% |
254
+ | Aspect | 100% |
255
+ | Morphology | 100% |
256
+ | Emphasis | 100% |
257
+ | Neutral | 100% |
258
+
259
+ ## Testing
260
+
261
+ Run the complete test suite:
262
+
263
+ ```bash
264
+ python -m pytest
265
+ ```
266
+
267
+ Current status:
268
+
269
+ ```text
270
+ 173 passed
271
+ ```
272
+
273
+ ## Benchmark
274
+
275
+ Run:
276
+
277
+ ```bash
278
+ python benchmarks/benchmark_sentiment.py
279
+ ```
280
+
281
+ ## Performance
282
+
283
+ On the current benchmark dataset of 100 samples:
284
+
285
+ ```text
286
+ Sentix: approximately 0.036 seconds
287
+ ```
288
+
289
+ This is approximately:
290
+
291
+ ```text
292
+ 0.36 milliseconds per sample
293
+ ```
294
+
295
+ Performance will vary depending on hardware and Python version.
296
+
297
+ ## Design Philosophy
298
+
299
+ Sentix focuses on:
300
+
301
+ - Lightweight implementation
302
+ - Explainability
303
+ - Rule-based reasoning
304
+ - No external machine learning model requirement
305
+ - Fast inference
306
+ - Transparent sentiment evidence
307
+
308
+ ## License
309
+
310
+ MIT License
311
+
312
+ ## Author
313
+
314
+ Sentix Contributors