textinsight-nlp 0.1.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 (57) hide show
  1. textinsight_nlp-0.1.0/.gitignore +34 -0
  2. textinsight_nlp-0.1.0/CHANGELOG.md +24 -0
  3. textinsight_nlp-0.1.0/LICENSE +21 -0
  4. textinsight_nlp-0.1.0/PKG-INFO +163 -0
  5. textinsight_nlp-0.1.0/README.md +125 -0
  6. textinsight_nlp-0.1.0/pyproject.toml +109 -0
  7. textinsight_nlp-0.1.0/src/textinsight/__init__.py +60 -0
  8. textinsight_nlp-0.1.0/src/textinsight/_data/__init__.py +1 -0
  9. textinsight_nlp-0.1.0/src/textinsight/_data/english.py +87 -0
  10. textinsight_nlp-0.1.0/src/textinsight/_data/hinglish.py +274 -0
  11. textinsight_nlp-0.1.0/src/textinsight/_data/sentiment_hinglish.json.gz +0 -0
  12. textinsight_nlp-0.1.0/src/textinsight/_data/sentiment_hybrid_head.json.gz +0 -0
  13. textinsight_nlp-0.1.0/src/textinsight/_data/sentiment_lexicon.py +105 -0
  14. textinsight_nlp-0.1.0/src/textinsight/_version.py +1 -0
  15. textinsight_nlp-0.1.0/src/textinsight/cli.py +66 -0
  16. textinsight_nlp-0.1.0/src/textinsight/core/__init__.py +61 -0
  17. textinsight_nlp-0.1.0/src/textinsight/core/base.py +106 -0
  18. textinsight_nlp-0.1.0/src/textinsight/core/config.py +163 -0
  19. textinsight_nlp-0.1.0/src/textinsight/core/exceptions.py +71 -0
  20. textinsight_nlp-0.1.0/src/textinsight/core/models.py +188 -0
  21. textinsight_nlp-0.1.0/src/textinsight/core/registry.py +161 -0
  22. textinsight_nlp-0.1.0/src/textinsight/core/results.py +106 -0
  23. textinsight_nlp-0.1.0/src/textinsight/core/validation.py +78 -0
  24. textinsight_nlp-0.1.0/src/textinsight/eval/__init__.py +6 -0
  25. textinsight_nlp-0.1.0/src/textinsight/eval/benchmark.py +120 -0
  26. textinsight_nlp-0.1.0/src/textinsight/eval/datasets.py +107 -0
  27. textinsight_nlp-0.1.0/src/textinsight/eval/metrics.py +49 -0
  28. textinsight_nlp-0.1.0/src/textinsight/langid/__init__.py +6 -0
  29. textinsight_nlp-0.1.0/src/textinsight/langid/detector.py +151 -0
  30. textinsight_nlp-0.1.0/src/textinsight/langid/ngram.py +67 -0
  31. textinsight_nlp-0.1.0/src/textinsight/preprocess/__init__.py +45 -0
  32. textinsight_nlp-0.1.0/src/textinsight/preprocess/_patterns.py +44 -0
  33. textinsight_nlp-0.1.0/src/textinsight/preprocess/cleaner.py +253 -0
  34. textinsight_nlp-0.1.0/src/textinsight/preprocess/hinglish.py +184 -0
  35. textinsight_nlp-0.1.0/src/textinsight/preprocess/normalizer.py +94 -0
  36. textinsight_nlp-0.1.0/src/textinsight/preprocess/tokenizer.py +184 -0
  37. textinsight_nlp-0.1.0/src/textinsight/py.typed +0 -0
  38. textinsight_nlp-0.1.0/src/textinsight/sentiment/__init__.py +8 -0
  39. textinsight_nlp-0.1.0/src/textinsight/sentiment/api.py +63 -0
  40. textinsight_nlp-0.1.0/src/textinsight/sentiment/classical.py +129 -0
  41. textinsight_nlp-0.1.0/src/textinsight/sentiment/features.py +147 -0
  42. textinsight_nlp-0.1.0/src/textinsight/sentiment/hybrid.py +133 -0
  43. textinsight_nlp-0.1.0/src/textinsight/sentiment/lexicon.py +128 -0
  44. textinsight_nlp-0.1.0/tests/conftest.py +42 -0
  45. textinsight_nlp-0.1.0/tests/test_clean.py +28 -0
  46. textinsight_nlp-0.1.0/tests/test_cleaner.py +154 -0
  47. textinsight_nlp-0.1.0/tests/test_config.py +92 -0
  48. textinsight_nlp-0.1.0/tests/test_eval.py +200 -0
  49. textinsight_nlp-0.1.0/tests/test_langid.py +129 -0
  50. textinsight_nlp-0.1.0/tests/test_models.py +137 -0
  51. textinsight_nlp-0.1.0/tests/test_normalizer.py +168 -0
  52. textinsight_nlp-0.1.0/tests/test_package.py +42 -0
  53. textinsight_nlp-0.1.0/tests/test_registry.py +179 -0
  54. textinsight_nlp-0.1.0/tests/test_results.py +57 -0
  55. textinsight_nlp-0.1.0/tests/test_sentiment.py +367 -0
  56. textinsight_nlp-0.1.0/tests/test_tokenizer.py +146 -0
  57. textinsight_nlp-0.1.0/tests/test_validation.py +86 -0
@@ -0,0 +1,34 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+
8
+ # Environments
9
+ .venv/
10
+ venv/
11
+ .env
12
+
13
+ # Tools
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ .coverage
18
+ coverage.xml
19
+ htmlcov/
20
+
21
+ # Editors / OS
22
+ .vscode/
23
+ .idea/
24
+ Thumbs.db
25
+ .DS_Store
26
+
27
+ # Large data and model files never belong in git
28
+ /data/
29
+ *.onnx
30
+ *.joblib
31
+ *.bin
32
+
33
+ # Office lock files
34
+ ~$*
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and the project uses [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.0] - Unreleased
8
+
9
+ ### Added
10
+ - Project skeleton: src-layout package, `pyproject.toml`, ruff, mypy, pytest, pre-commit, GitHub Actions CI.
11
+ - Core foundation: configuration, exception hierarchy, input validation, typed result classes,
12
+ backend base class, backend registry with `"auto"` selection, and a model manager with
13
+ on-disk caching, SHA-256 verification and offline mode.
14
+ - Configurable `clean()`: HTML, URLs, emails, mentions, hashtags, emojis, numbers, punctuation.
15
+ - `tokenize()` and `sentences()` for informal English and Hinglish, including Devanagari and the danda.
16
+ - Hinglish spelling normalization: `normalize_hinglish()` and `cluster_variants()` for mining new variants.
17
+ - `normalize()` and `remove_stopwords()` for English and Hinglish.
18
+ - `detect_language()` with a from-scratch character n-gram classifier.
19
+ - `sentiment()` with three backends: `lexicon` (English and Hinglish, with post-word negation),
20
+ bundled `classical` (NB-LR with Hinglish spelling features, trained on SentiMix), and optional
21
+ `hybrid` (blended with HingBERT, via the `transformers` extra). Short, plain text falls back to the lexicon when the model
22
+ says neutral but the lexicon is clear.
23
+ - Evaluation tools: SentiMix loader, metrics, and the `textinsight benchmark` command.
24
+ - Benchmarks on the held-out SentiMix test split, and a model card.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harsh Vardhan Ajmera
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.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.5
2
+ Name: textinsight-nlp
3
+ Version: 0.1.0
4
+ Summary: Lightweight, offline-first NLP for English and Hinglish text, with pluggable backends.
5
+ Project-URL: Homepage, https://github.com/harsh01103/textinsight
6
+ Project-URL: Issues, https://github.com/harsh01103/textinsight/issues
7
+ Author: Harsh Vardhan Ajmera
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: code-mixed,hinglish,keywords,nlp,sentiment,summarization,text-analysis
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Text Processing :: Linguistic
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Provides-Extra: dev
24
+ Requires-Dist: build>=1.2; extra == 'dev'
25
+ Requires-Dist: mypy>=1.10; extra == 'dev'
26
+ Requires-Dist: pre-commit>=3.7; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: ruff>=0.6; extra == 'dev'
30
+ Requires-Dist: twine>=5; extra == 'dev'
31
+ Provides-Extra: training
32
+ Requires-Dist: scikit-learn>=1.5; extra == 'training'
33
+ Requires-Dist: vadersentiment>=3.3.2; extra == 'training'
34
+ Provides-Extra: transformers
35
+ Requires-Dist: torch>=2.2; extra == 'transformers'
36
+ Requires-Dist: transformers>=4.40; extra == 'transformers'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # TextInsight
40
+
41
+ **Lightweight, offline-first NLP for English and Hinglish text, with pluggable backends.**
42
+
43
+ > Status: alpha. Preprocessing, language detection and sentiment work; other tasks arrive in upcoming releases.
44
+ > See `TextInsight_Architecture_and_Roadmap.docx` for the full plan.
45
+
46
+ ## Why TextInsight?
47
+
48
+ - **Built for Hinglish** – handles code-mixed text such as *"yeh phone mast hai but battery bekaar hai"*: spelling variants, Hindi word order for negation, and a model trained on real Hinglish tweets.
49
+ - **Lightweight by default** – small base install; heavy models are optional extras.
50
+ - **No surprises** – importing the library never downloads anything.
51
+ - **Pluggable backends** – swap lexicon, classical ML, ONNX, transformer or LLM implementations with one argument.
52
+ - **Honest benchmarks** – every backend ships with measured results.
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install textinsight-nlp
58
+ ```
59
+
60
+ The package installs as `textinsight-nlp` and is imported as `textinsight`.
61
+
62
+ ## Quick start
63
+
64
+ ```python
65
+ import textinsight as ti
66
+
67
+ ti.clean("Visit https://example.com now!", lowercase=True) # 'visit now!'
68
+ ti.tokenize("Don't miss it :) #sale") # ["Don't", 'miss', 'it', ':)', '#sale']
69
+ ti.sentences("Dr. Rao aaye. yeh accha hai!") # ['Dr. Rao aaye.', 'yeh accha hai!']
70
+ ti.normalize_hinglish("bohot acha hai") # 'bahut accha hai'
71
+ ti.detect_language("yeh phone mast hai but battery bekaar").language # 'hi-en'
72
+ ti.sentiment("bahut accha product hai") # SentimentResult(label='positive', ...)
73
+ ti.sentiment("yeh accha nahi hai", backend="lexicon") # handles Hindi negation
74
+
75
+ ti.list_backends() # registered backends
76
+ ti.config.offline = True # never download models
77
+ ```
78
+
79
+ Language labels are `en`, `hi` (mainly Devanagari), `hi-en` (code-mixed or romanized Hindi)
80
+ and `und` (undetermined).
81
+
82
+ ## Benchmarks
83
+
84
+ Sentiment on the held-out test split of [SentiMix](https://doi.org/10.5281/zenodo.3974927)
85
+ (3,000 real Hinglish tweets):
86
+
87
+ | Method | Accuracy | Macro F1 | Weighted F1 |
88
+ |---|---|---|---|
89
+ | Majority class | 0.367 | 0.179 | 0.197 |
90
+ | VADER | 0.492 | 0.470 | 0.475 |
91
+ | TextInsight `lexicon` | 0.561 | 0.540 | 0.546 |
92
+ | **TextInsight `classical`** (default, 529 KB, no dependencies) | **0.702** | **0.707** | **0.703** |
93
+ | **TextInsight `hybrid`** (optional transformer blend) | **0.723** | **0.728** | **0.725** |
94
+
95
+ Cross-validated macro F1 on the other 17,000 tweets is lower and more conservative: 0.639 for
96
+ `classical` and 0.666 for `hybrid`. Word-level language detection on the test tweets: 72.7%.
97
+
98
+ Short, plain sentences such as reviews use a lexicon fallback, because a model trained on tweets
99
+ reads them as neutral too often. On 60 hand-written review-style Hinglish sentences kept back for
100
+ this check, macro F1 rose from 0.581 to 0.819 for `classical` and from 0.499 to 0.834 for `hybrid`.
101
+ That set is small and not independent, so treat it as a behaviour check.
102
+
103
+ The test-split scores above are for tweets only. See the
104
+ [model card](docs/model_cards/sentiment_classical.md) for method, limitations and bias.
105
+
106
+ To reproduce them, install the `training` extra, download the dataset and run:
107
+
108
+ ```bash
109
+ textinsight benchmark sentiment --data-dir path/to/Hinglish --split test
110
+ ```
111
+
112
+ ## Most accurate option
113
+
114
+ ```bash
115
+ pip install "textinsight-nlp[transformers]"
116
+ ```
117
+
118
+ ```python
119
+ ti.sentiment("zabardast movie thi, maza aa gaya", backend="hybrid")
120
+ ```
121
+
122
+ First use downloads the 438 MB HingBERT encoder, so `hybrid` runs only when you ask for it.
123
+
124
+ ## Credits
125
+
126
+ The bundled sentiment model derives from SentiMix (CC-BY-4.0): Patwa et al., "SemEval-2020
127
+ Task 9: Overview of Sentiment Analysis of Code-Mixed Tweets", SemEval-2020. The `hybrid` backend
128
+ uses HingBERT (CC-BY-4.0): Joshi, "L3Cube-HingCorpus and HingBERT", 2022.
129
+
130
+ ## Planned features
131
+
132
+ | Release | Features |
133
+ |---|---|
134
+ | 0.1.0 | Preprocessing, language ID, English + Hinglish sentiment, benchmarks |
135
+ | 0.2.0 | Keywords (TF-IDF, RAKE, TextRank), extractive summarization |
136
+ | 0.3.0 | Aspect sentiment, text stats, PII redaction, `analyze()`, CLI, pandas |
137
+ | 1.0.0 | Optional ONNX / transformer / LLM backends, docs site, live demo |
138
+
139
+ ## Development
140
+
141
+ ```bash
142
+ python -m venv .venv
143
+ .venv\Scripts\activate # Windows (source .venv/bin/activate on macOS/Linux)
144
+ pip install -e ".[dev]"
145
+ pre-commit install
146
+
147
+ pytest # tests + coverage
148
+ ruff check . && ruff format --check .
149
+ mypy
150
+ ```
151
+
152
+ ## Configuration
153
+
154
+ | Setting | Environment variable | Default |
155
+ |---|---|---|
156
+ | `config.cache_dir` | `TEXTINSIGHT_CACHE_DIR` | OS user cache folder + `/textinsight` |
157
+ | `config.offline` | `TEXTINSIGHT_OFFLINE` | `False` |
158
+ | `config.device` | `TEXTINSIGHT_DEVICE` | `"cpu"` |
159
+ | `config.max_input_chars` | `TEXTINSIGHT_MAX_INPUT_CHARS` | `1_000_000` |
160
+
161
+ ## License
162
+
163
+ MIT
@@ -0,0 +1,125 @@
1
+ # TextInsight
2
+
3
+ **Lightweight, offline-first NLP for English and Hinglish text, with pluggable backends.**
4
+
5
+ > Status: alpha. Preprocessing, language detection and sentiment work; other tasks arrive in upcoming releases.
6
+ > See `TextInsight_Architecture_and_Roadmap.docx` for the full plan.
7
+
8
+ ## Why TextInsight?
9
+
10
+ - **Built for Hinglish** – handles code-mixed text such as *"yeh phone mast hai but battery bekaar hai"*: spelling variants, Hindi word order for negation, and a model trained on real Hinglish tweets.
11
+ - **Lightweight by default** – small base install; heavy models are optional extras.
12
+ - **No surprises** – importing the library never downloads anything.
13
+ - **Pluggable backends** – swap lexicon, classical ML, ONNX, transformer or LLM implementations with one argument.
14
+ - **Honest benchmarks** – every backend ships with measured results.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install textinsight-nlp
20
+ ```
21
+
22
+ The package installs as `textinsight-nlp` and is imported as `textinsight`.
23
+
24
+ ## Quick start
25
+
26
+ ```python
27
+ import textinsight as ti
28
+
29
+ ti.clean("Visit https://example.com now!", lowercase=True) # 'visit now!'
30
+ ti.tokenize("Don't miss it :) #sale") # ["Don't", 'miss', 'it', ':)', '#sale']
31
+ ti.sentences("Dr. Rao aaye. yeh accha hai!") # ['Dr. Rao aaye.', 'yeh accha hai!']
32
+ ti.normalize_hinglish("bohot acha hai") # 'bahut accha hai'
33
+ ti.detect_language("yeh phone mast hai but battery bekaar").language # 'hi-en'
34
+ ti.sentiment("bahut accha product hai") # SentimentResult(label='positive', ...)
35
+ ti.sentiment("yeh accha nahi hai", backend="lexicon") # handles Hindi negation
36
+
37
+ ti.list_backends() # registered backends
38
+ ti.config.offline = True # never download models
39
+ ```
40
+
41
+ Language labels are `en`, `hi` (mainly Devanagari), `hi-en` (code-mixed or romanized Hindi)
42
+ and `und` (undetermined).
43
+
44
+ ## Benchmarks
45
+
46
+ Sentiment on the held-out test split of [SentiMix](https://doi.org/10.5281/zenodo.3974927)
47
+ (3,000 real Hinglish tweets):
48
+
49
+ | Method | Accuracy | Macro F1 | Weighted F1 |
50
+ |---|---|---|---|
51
+ | Majority class | 0.367 | 0.179 | 0.197 |
52
+ | VADER | 0.492 | 0.470 | 0.475 |
53
+ | TextInsight `lexicon` | 0.561 | 0.540 | 0.546 |
54
+ | **TextInsight `classical`** (default, 529 KB, no dependencies) | **0.702** | **0.707** | **0.703** |
55
+ | **TextInsight `hybrid`** (optional transformer blend) | **0.723** | **0.728** | **0.725** |
56
+
57
+ Cross-validated macro F1 on the other 17,000 tweets is lower and more conservative: 0.639 for
58
+ `classical` and 0.666 for `hybrid`. Word-level language detection on the test tweets: 72.7%.
59
+
60
+ Short, plain sentences such as reviews use a lexicon fallback, because a model trained on tweets
61
+ reads them as neutral too often. On 60 hand-written review-style Hinglish sentences kept back for
62
+ this check, macro F1 rose from 0.581 to 0.819 for `classical` and from 0.499 to 0.834 for `hybrid`.
63
+ That set is small and not independent, so treat it as a behaviour check.
64
+
65
+ The test-split scores above are for tweets only. See the
66
+ [model card](docs/model_cards/sentiment_classical.md) for method, limitations and bias.
67
+
68
+ To reproduce them, install the `training` extra, download the dataset and run:
69
+
70
+ ```bash
71
+ textinsight benchmark sentiment --data-dir path/to/Hinglish --split test
72
+ ```
73
+
74
+ ## Most accurate option
75
+
76
+ ```bash
77
+ pip install "textinsight-nlp[transformers]"
78
+ ```
79
+
80
+ ```python
81
+ ti.sentiment("zabardast movie thi, maza aa gaya", backend="hybrid")
82
+ ```
83
+
84
+ First use downloads the 438 MB HingBERT encoder, so `hybrid` runs only when you ask for it.
85
+
86
+ ## Credits
87
+
88
+ The bundled sentiment model derives from SentiMix (CC-BY-4.0): Patwa et al., "SemEval-2020
89
+ Task 9: Overview of Sentiment Analysis of Code-Mixed Tweets", SemEval-2020. The `hybrid` backend
90
+ uses HingBERT (CC-BY-4.0): Joshi, "L3Cube-HingCorpus and HingBERT", 2022.
91
+
92
+ ## Planned features
93
+
94
+ | Release | Features |
95
+ |---|---|
96
+ | 0.1.0 | Preprocessing, language ID, English + Hinglish sentiment, benchmarks |
97
+ | 0.2.0 | Keywords (TF-IDF, RAKE, TextRank), extractive summarization |
98
+ | 0.3.0 | Aspect sentiment, text stats, PII redaction, `analyze()`, CLI, pandas |
99
+ | 1.0.0 | Optional ONNX / transformer / LLM backends, docs site, live demo |
100
+
101
+ ## Development
102
+
103
+ ```bash
104
+ python -m venv .venv
105
+ .venv\Scripts\activate # Windows (source .venv/bin/activate on macOS/Linux)
106
+ pip install -e ".[dev]"
107
+ pre-commit install
108
+
109
+ pytest # tests + coverage
110
+ ruff check . && ruff format --check .
111
+ mypy
112
+ ```
113
+
114
+ ## Configuration
115
+
116
+ | Setting | Environment variable | Default |
117
+ |---|---|---|
118
+ | `config.cache_dir` | `TEXTINSIGHT_CACHE_DIR` | OS user cache folder + `/textinsight` |
119
+ | `config.offline` | `TEXTINSIGHT_OFFLINE` | `False` |
120
+ | `config.device` | `TEXTINSIGHT_DEVICE` | `"cpu"` |
121
+ | `config.max_input_chars` | `TEXTINSIGHT_MAX_INPUT_CHARS` | `1_000_000` |
122
+
123
+ ## License
124
+
125
+ MIT
@@ -0,0 +1,109 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "textinsight-nlp"
7
+ dynamic = ["version"]
8
+ description = "Lightweight, offline-first NLP for English and Hinglish text, with pluggable backends."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Harsh Vardhan Ajmera" }]
14
+ keywords = ["nlp", "sentiment", "hinglish", "code-mixed", "keywords", "summarization", "text-analysis"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Science/Research",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Topic :: Text Processing :: Linguistic",
26
+ "Typing :: Typed",
27
+ ]
28
+ # Runtime dependencies are added in the phase that first uses them
29
+ # (numpy / scikit-learn / regex arrive with preprocessing and sentiment).
30
+ dependencies = []
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "pytest>=8",
35
+ "pytest-cov>=5",
36
+ "ruff>=0.6",
37
+ "mypy>=1.10",
38
+ "pre-commit>=3.7",
39
+ "build>=1.2",
40
+ "twine>=5",
41
+ ]
42
+ transformers = [
43
+ "torch>=2.2",
44
+ "transformers>=4.40",
45
+ ]
46
+ training = [
47
+ "scikit-learn>=1.5",
48
+ "vaderSentiment>=3.3.2",
49
+ ]
50
+
51
+ [project.scripts]
52
+ textinsight = "textinsight.cli:main"
53
+
54
+ [project.urls]
55
+ Homepage = "https://github.com/harsh01103/textinsight"
56
+ Issues = "https://github.com/harsh01103/textinsight/issues"
57
+
58
+ [tool.hatch.version]
59
+ path = "src/textinsight/_version.py"
60
+
61
+ [tool.hatch.build.targets.wheel]
62
+ packages = ["src/textinsight"]
63
+
64
+ [tool.hatch.build.targets.sdist]
65
+ include = ["src/textinsight", "tests", "README.md", "CHANGELOG.md", "LICENSE"]
66
+
67
+ # ---------------------------------------------------------------- pytest
68
+ [tool.pytest.ini_options]
69
+ testpaths = ["tests"]
70
+ addopts = "-ra --strict-markers --cov=textinsight --cov-report=term-missing"
71
+ markers = [
72
+ "slow: tests that load real models or hit the network (deselect with -m 'not slow')",
73
+ ]
74
+
75
+ [tool.coverage.run]
76
+ branch = true
77
+ source = ["textinsight"]
78
+
79
+ [tool.coverage.report]
80
+ fail_under = 90
81
+ exclude_also = ["if TYPE_CHECKING:", "raise NotImplementedError", "\\.\\.\\."]
82
+
83
+ # ---------------------------------------------------------------- ruff
84
+ [tool.ruff]
85
+ line-length = 100
86
+ target-version = "py310"
87
+ src = ["src", "tests"]
88
+
89
+ [tool.ruff.lint]
90
+ select = ["E", "F", "W", "I", "B", "UP", "SIM", "RUF", "PT", "N"]
91
+ ignore = ["SIM905"] # long word lists read better as one split string
92
+
93
+ [tool.ruff.lint.per-file-ignores]
94
+ # Tests use non-ASCII text on purpose (Devanagari, full-width letters, curly quotes).
95
+ "tests/*" = ["RUF001"]
96
+ # Curly quotes are matched deliberately when tokenizing.
97
+ "src/textinsight/preprocess/*" = ["RUF001"]
98
+
99
+ # ---------------------------------------------------------------- mypy
100
+ [tool.mypy]
101
+ python_version = "3.10"
102
+ mypy_path = "src"
103
+ packages = ["textinsight"]
104
+ strict = true
105
+ warn_unreachable = true
106
+
107
+ [[tool.mypy.overrides]]
108
+ module = ["torch", "transformers"]
109
+ ignore_missing_imports = true
@@ -0,0 +1,60 @@
1
+ """TextInsight: lightweight, offline-first NLP for English and Hinglish text.
2
+
3
+ Importing this package is cheap: it never downloads models or opens network
4
+ connections. Models are fetched lazily the first time a backend needs them.
5
+ """
6
+
7
+ import logging
8
+
9
+ from ._version import __version__
10
+ from .core import (
11
+ BackendInfo,
12
+ BackendNotAvailableError,
13
+ Config,
14
+ ConfigError,
15
+ InvalidInputError,
16
+ Keyword,
17
+ KeywordResult,
18
+ LanguageResult,
19
+ ModelDownloadError,
20
+ SentimentResult,
21
+ SummaryResult,
22
+ TextInsightError,
23
+ UnknownBackendError,
24
+ UnsupportedLanguageError,
25
+ config,
26
+ list_backends,
27
+ )
28
+ from .langid import detect_language
29
+ from .preprocess import clean, normalize, normalize_hinglish, remove_stopwords, sentences, tokenize
30
+ from .sentiment import sentiment
31
+
32
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
33
+
34
+ __all__ = [
35
+ "BackendInfo",
36
+ "BackendNotAvailableError",
37
+ "Config",
38
+ "ConfigError",
39
+ "InvalidInputError",
40
+ "Keyword",
41
+ "KeywordResult",
42
+ "LanguageResult",
43
+ "ModelDownloadError",
44
+ "SentimentResult",
45
+ "SummaryResult",
46
+ "TextInsightError",
47
+ "UnknownBackendError",
48
+ "UnsupportedLanguageError",
49
+ "__version__",
50
+ "clean",
51
+ "config",
52
+ "detect_language",
53
+ "list_backends",
54
+ "normalize",
55
+ "normalize_hinglish",
56
+ "remove_stopwords",
57
+ "sentences",
58
+ "sentiment",
59
+ "tokenize",
60
+ ]
@@ -0,0 +1 @@
1
+ """Small word lists bundled with the package."""
@@ -0,0 +1,87 @@
1
+ """Common English words and stopwords."""
2
+
3
+ from __future__ import annotations
4
+
5
+ # Negations are left out on purpose: dropping "not" flips the meaning of a sentence.
6
+ STOPWORDS_EN = frozenset(
7
+ """
8
+ a about above after again all also am an and any are as at be because been before being
9
+ below between both but by can could did do does doing down during each few for from
10
+ further had has have having he her here hers herself him himself his how i if in into is
11
+ it its itself just me more most my myself of off on once only or other our ours ourselves
12
+ out over own same she should so some such than that the their theirs them themselves then
13
+ there these they this those through to too under until up very was we were what when
14
+ where which while who whom why will with would you your yours yourself yourselves
15
+ """.split()
16
+ )
17
+
18
+ ENGLISH_COMMON = frozenset(
19
+ """
20
+ a about above absolutely across actually add after again against ago agree air all allow
21
+ almost alone along already also although always am amazing among an and angry animal
22
+ annoying another answer any anyone anything app apple apps are area arm around arrive art
23
+ as ask at attention available average awesome away awful baby back bad bag bank battery
24
+ be beautiful because become bed been before began begin behind being believe below best
25
+ better between big bill black blue boat body book boring both box boy brand break bring
26
+ broke broken brother brought build building bus business busy but buy by call came camera
27
+ can cannot car card care carry case cause change charge charger cheap check child
28
+ children choose city class clean clear close clothes coffee cold college color come
29
+ comfortable company complete computer confused consider contact continue cool cost could
30
+ country couple course cover create crazy customer cut dark data date daughter day days
31
+ dead deal dear decide delivered delivery design did die different difficult dinner
32
+ disappointed disappointing do doctor does doing dog dollar done door down dream drink
33
+ drive drop during each early earth easy eat economy education effect either else email
34
+ end enjoy enough entire even evening ever every everyone everything exactly example
35
+ excellent except excited expect expensive experience explain eye face fact fail failed
36
+ fair fake fall family fan fantastic far fast father fault favorite feature features feel
37
+ feeling few field fight figure fill film final finally find fine finish first fit five
38
+ fix flight floor follow food foot for force forget form forward found four free fresh
39
+ friend friends from front full fun funny future game garden gave get getting girl give
40
+ given glad go goes going gone good got government great green ground group grow guess guy
41
+ guys had hair half hand happen happened happy hard has hate have having he head health
42
+ hear heard heart heavy hello help her here high him himself his history hit hold holiday
43
+ home hope horrible hospital hot hotel hour hours house how however huge human hundred
44
+ hungry hurt husband i idea if ignore important improve in include including increase
45
+ indeed information inside instead interest interesting internet into is issue issues it
46
+ item its itself job join just keep kept key kid kids kind kitchen knew know known lack
47
+ laptop large last late later laugh law lay lead learn least leave left less let letter
48
+ level life light like likely line list listen little live living local long look looking
49
+ lose lost lot lots love lovely low lunch machine made main major make making man manager
50
+ many market marriage matter may maybe me mean meant meet meeting member men message met
51
+ might mind minute minutes miss mobile model moment money month months more morning most
52
+ mother move movie movies much music must my myself name nation near nearly need needed
53
+ never new news next nice night nine no nobody none nor not note nothing notice now number
54
+ of off offer office often oh ok okay old on once one online only open opinion option or
55
+ order other others our out outside over own owner page paid pain paper parents park part
56
+ particular party pass past pay payment people perfect perhaps person personal phone pick
57
+ picture piece place plan play player please point police policy poor popular possible
58
+ power prefer present president pretty price probably problem problems process product
59
+ products program promise proper provide public pull purchase purchased put quality
60
+ question quick quickly quite rain raise ran rather reach read ready real really reason
61
+ receive received recent recommend red refund refused relationship remember remove repair
62
+ replace replacement reply report rest restaurant result return review reviews rich ride
63
+ right road room rude rule run sad safe said sale same saturday save saw say says scared
64
+ school screen sea season seat second see seem seen sell send sense sent series serious
65
+ service set seven several shall share she ship shipping shirt shop short should show
66
+ shows side sign simple since sing sister sit site situation six size sleep slow small
67
+ smart smell smile so social software some someone something sometimes son song soon sorry
68
+ sound space speak special speed spend spent sport staff stand standard star start started
69
+ state station stay still stop store story street strong student study stuff stupid style
70
+ subject such suddenly summer sunday support suppose sure surprised sweet system table
71
+ take taken talk taste tea teach teacher team tell ten terrible test than thank thanks
72
+ that the their them themselves then there therefore these they thing things think third
73
+ this those though thought thousand three through throughout thus ticket till time tired
74
+ to today together told tomorrow tonight too took top total touch towards town traffic
75
+ train travel tried trip trouble true trust truth try trying turn twenty two type under
76
+ understand unfortunately unit university until up update upon us use used useful useless
77
+ user using usually value very video view village visit voice wait waiting walk wall want
78
+ wanted war warm warranty was wash waste watch water way we wear weather website week
79
+ weekend weeks weight welcome well went were west what whatever when where whether which
80
+ while white who whole why wife will win window wish with within without woman women won
81
+ wonder wonderful word work worked working world worried worse worst worth would write
82
+ writing wrong yeah year years yellow yes yesterday yet you young your yourself
83
+ don't doesn't didn't won't can't isn't aren't wasn't weren't haven't hasn't hadn't
84
+ wouldn't shouldn't couldn't i'm i've i'll i'd you're you've you'll they're they've
85
+ we're we've it's that's there's what's let's he's she's
86
+ """.split()
87
+ )