SqueakyCleanText 0.5.0__tar.gz → 0.5.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.
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/PKG-INFO +73 -46
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/README.md +58 -41
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/SqueakyCleanText.egg-info/PKG-INFO +73 -46
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/pyproject.toml +22 -5
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/__init__.py +1 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/LICENSE +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/SqueakyCleanText.egg-info/SOURCES.txt +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/SqueakyCleanText.egg-info/dependency_links.txt +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/SqueakyCleanText.egg-info/requires.txt +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/SqueakyCleanText.egg-info/top_level.txt +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/config.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/sct.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/__init__.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/constants.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/contact.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/datetime.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/gliner_adapter.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/ner.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/normtext.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/onnx_pipeline.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/resources.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/special.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/stopwords.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/sct/utils/torch_pipeline.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/setup.cfg +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/setup.py +0 -0
- {squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/tests/test_sct.py +0 -0
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SqueakyCleanText
|
|
3
|
-
Version: 0.5.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.5.2
|
|
4
|
+
Summary: Text preprocessing & PII anonymization pipeline for NLP/ML: ONNX NER ensemble, language detection, stopword removal, and configurable token replacement.
|
|
5
5
|
Author: Rehan Fazal
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/rhnfzl/SqueakyCleanText
|
|
8
|
-
|
|
8
|
+
Project-URL: Repository, https://github.com/rhnfzl/SqueakyCleanText
|
|
9
|
+
Project-URL: Issues, https://github.com/rhnfzl/SqueakyCleanText/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/rhnfzl/SqueakyCleanText/releases
|
|
11
|
+
Project-URL: llms.txt, https://github.com/rhnfzl/SqueakyCleanText/blob/main/llms.txt
|
|
12
|
+
Keywords: text cleaning,text preprocessing,NLP,natural language processing,named entity recognition,NER,anonymization,PII removal,data cleaning,machine learning,ONNX,language detection
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
18
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Natural Language :: English
|
|
9
21
|
Classifier: Programming Language :: Python :: 3
|
|
10
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
24
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
25
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
26
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
-
Classifier: Topic :: Text Processing
|
|
17
27
|
Requires-Python: >=3.11
|
|
18
28
|
Description-Content-Type: text/markdown
|
|
19
29
|
License-File: LICENSE
|
|
@@ -70,21 +80,25 @@ Dynamic: license-file
|
|
|
70
80
|
A comprehensive text cleaning and preprocessing pipeline for machine learning and NLP tasks.
|
|
71
81
|
</div>
|
|
72
82
|
|
|
83
|
+
> **Using an AI coding assistant?** This repo includes an [`llms.txt`](https://github.com/rhnfzl/SqueakyCleanText/blob/main/llms.txt) with the full API surface, config reference, and Q&A - optimised for Claude, Cursor, Copilot, and ChatGPT.
|
|
84
|
+
|
|
73
85
|
In the world of machine learning and natural language processing, clean and well-structured text data is crucial for building effective downstream models and managing token limits in language models.
|
|
74
86
|
|
|
75
|
-
SqueakyCleanText simplifies the process by automatically addressing common text issues, ensuring your data is clean and well-structured with minimal effort on your part.
|
|
87
|
+
SqueakyCleanText simplifies the process by automatically addressing common text issues - removing PII, anonymizing named entities (persons, organisations, locations), and ensuring your data is clean and well-structured for language models and classical ML pipelines with minimal effort on your part.
|
|
76
88
|
|
|
77
89
|
### Key Features
|
|
78
90
|
|
|
79
91
|
- **Named Entity Recognition (NER)**:
|
|
80
92
|
- Multi-backend: ONNX (default, torch-free), PyTorch, GLiNER, and ensemble modes
|
|
81
93
|
- Zero-shot custom entities via GLiNER (e.g., PRODUCT, EVENT, SKILL)
|
|
82
|
-
- Multi-language support (English, Dutch, German, Spanish)
|
|
94
|
+
- Multi-language support (English, Dutch, German, Spanish, French, Portuguese, Italian)
|
|
83
95
|
- Ensemble voting across backends for improved accuracy
|
|
84
96
|
- Configurable confidence thresholds
|
|
85
97
|
- Lazy model loading (models load on demand per language)
|
|
86
|
-
-
|
|
98
|
+
- Shared ONNX sessions across same-model languages (~600 MB RAM saved)
|
|
99
|
+
- Automatic text chunking for long documents (CJK/Arabic safe)
|
|
87
100
|
- GPU acceleration support (CUDA for ONNX and PyTorch)
|
|
101
|
+
- Model warm-up API to pre-load on startup
|
|
88
102
|
- **Text Normalization**:
|
|
89
103
|
- Corrects text encoding problems and handles bad Unicode characters
|
|
90
104
|
- Removes or replaces HTML tags and URLs with configurable tokens
|
|
@@ -99,7 +113,7 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
99
113
|
- Smart case folding (preserves NER tokens like `<PERSON>`)
|
|
100
114
|
- **Language Support**:
|
|
101
115
|
- Automatic language detection (English, Dutch, German, Spanish)
|
|
102
|
-
- Language-specific NER models
|
|
116
|
+
- Language-specific NER models; French, Portuguese, Italian via multilingual model
|
|
103
117
|
- Language-aware stopword removal
|
|
104
118
|
- Extensible: add custom languages with stopwords, month names, and NER models
|
|
105
119
|
- **Dual Output Formats**:
|
|
@@ -108,7 +122,9 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
108
122
|
- **Performance**:
|
|
109
123
|
- ONNX Runtime inference (torch-free base install, ~3-5x faster than PyTorch)
|
|
110
124
|
- Thread-parallel batch processing via `ThreadPoolExecutor`
|
|
125
|
+
- Async batch processing (`aprocess_batch`) for FastAPI / aiohttp
|
|
111
126
|
- Lazy model loading (only loads models as needed)
|
|
127
|
+
- Shared ONNX sessions for same-model languages (saves ~600 MB for FR/PT/IT)
|
|
112
128
|
- Memory-efficient processing of large texts
|
|
113
129
|
- GPU acceleration (CUDA) for both ONNX and PyTorch backends
|
|
114
130
|
|
|
@@ -141,7 +157,7 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
141
157
|
pip install SqueakyCleanText
|
|
142
158
|
```
|
|
143
159
|
|
|
144
|
-
The base install uses **ONNX Runtime** for NER inference
|
|
160
|
+
The base install uses **ONNX Runtime** for NER inference - no PyTorch or Transformers required.
|
|
145
161
|
|
|
146
162
|
### Optional Extras
|
|
147
163
|
|
|
@@ -216,7 +232,7 @@ cfg = TextCleanerConfig(
|
|
|
216
232
|
gliner_labels=('person', 'organization', 'location', 'product', 'event'),
|
|
217
233
|
gliner_label_map={
|
|
218
234
|
'person': 'PER', 'organization': 'ORG', 'location': 'LOC',
|
|
219
|
-
# 'product' and 'event' are unmapped
|
|
235
|
+
# 'product' and 'event' are unmapped - they become <PRODUCT>, <EVENT> tokens
|
|
220
236
|
},
|
|
221
237
|
gliner_threshold=0.4,
|
|
222
238
|
)
|
|
@@ -306,7 +322,7 @@ SqueakyCleanText supports five NER backends, selectable via the `ner_backend` co
|
|
|
306
322
|
|
|
307
323
|
| Backend | Description | Dependencies | Best for |
|
|
308
324
|
|---------|-------------|-------------|----------|
|
|
309
|
-
| `onnx` (default) | ONNX Runtime inference with quantized XLM-RoBERTa models | Base install | Production
|
|
325
|
+
| `onnx` (default) | ONNX Runtime inference with quantized XLM-RoBERTa models | Base install | Production: fast, torch-free |
|
|
310
326
|
| `torch` | PyTorch/Transformers pipeline with full XLM-RoBERTa models | `[torch]` extra | Compatibility with existing PyTorch workflows |
|
|
311
327
|
| `gliner` | GLiNER zero-shot NER with custom entity labels | `[gliner]` or `[gliner2]` extra | Custom entity types (PRODUCT, SKILL, EVENT, etc.) |
|
|
312
328
|
| `ensemble_onnx` | ONNX + GLiNER ensemble voting | `[gliner]` extra | Maximum recall with custom entities |
|
|
@@ -320,7 +336,8 @@ SqueakyCleanText supports five NER backends, selectable via the `ner_backend` co
|
|
|
320
336
|
| Dutch | [`rhnfzl/xlm-roberta-large-conll02-dutch-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll02-dutch-onnx) |
|
|
321
337
|
| German | [`rhnfzl/xlm-roberta-large-conll03-german-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll03-german-onnx) |
|
|
322
338
|
| Spanish | [`rhnfzl/xlm-roberta-large-conll02-spanish-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll02-spanish-onnx) |
|
|
323
|
-
|
|
|
339
|
+
| French / Portuguese / Italian | [`rhnfzl/wikineural-multilingual-ner-onnx`](https://huggingface.co/rhnfzl/wikineural-multilingual-ner-onnx) (shared session) |
|
|
340
|
+
| Multilingual (fallback) | [`rhnfzl/wikineural-multilingual-ner-onnx`](https://huggingface.co/rhnfzl/wikineural-multilingual-ner-onnx) |
|
|
324
341
|
|
|
325
342
|
### GLiNER Label Mapping
|
|
326
343
|
|
|
@@ -351,6 +368,28 @@ Processes the input text and returns a tuple containing:
|
|
|
351
368
|
|
|
352
369
|
Processes multiple texts using thread-parallel execution. Each result follows the same format as `process()`.
|
|
353
370
|
|
|
371
|
+
#### `aprocess_batch(texts: List[str], batch_size: int = None) -> List[Tuple[str, Optional[str], Optional[str]]]`
|
|
372
|
+
|
|
373
|
+
Async version of `process_batch` for use with asyncio-based frameworks (FastAPI, aiohttp). Runs the batch in a thread-pool executor so it does not block the event loop:
|
|
374
|
+
|
|
375
|
+
```python
|
|
376
|
+
from sct import TextCleaner
|
|
377
|
+
|
|
378
|
+
cleaner = TextCleaner()
|
|
379
|
+
|
|
380
|
+
# In an async context (FastAPI route, aiohttp handler, etc.)
|
|
381
|
+
results = await cleaner.aprocess_batch(texts)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### `warmup(languages: Optional[List[str]] = None) -> None`
|
|
385
|
+
|
|
386
|
+
Pre-loads NER models to avoid first-request latency. Call once during application startup:
|
|
387
|
+
|
|
388
|
+
```python
|
|
389
|
+
cleaner = TextCleaner()
|
|
390
|
+
cleaner.warmup(['ENGLISH', 'DUTCH']) # or warmup() for all supported languages
|
|
391
|
+
```
|
|
392
|
+
|
|
354
393
|
### `TextCleanerConfig`
|
|
355
394
|
|
|
356
395
|
Immutable (frozen) dataclass. Create modified copies with `dataclasses.replace()`:
|
|
@@ -413,6 +452,7 @@ new_cfg = dataclasses.replace(cfg, check_ner_process=False)
|
|
|
413
452
|
| `ner_backend` | `'onnx'` | Backend: `onnx`, `torch`, `gliner`, `ensemble_onnx`, `ensemble_torch` |
|
|
414
453
|
| `positional_tags` | `('PER', 'LOC', 'ORG', 'MISC')` | Entity types to recognize |
|
|
415
454
|
| `ner_confidence_threshold` | `0.85` | Minimum confidence score |
|
|
455
|
+
| `ner_batch_size` | `8` | Inference batch size (must be >= 1) |
|
|
416
456
|
| `ner_models` | `None` | Language-keyed dict of ONNX model repo IDs |
|
|
417
457
|
| `torch_ner_models` | `None` | Language-keyed dict of PyTorch model repo IDs |
|
|
418
458
|
| `gliner_model` | `None` | GLiNER model ID (required for gliner/ensemble backends) |
|
|
@@ -421,6 +461,7 @@ new_cfg = dataclasses.replace(cfg, check_ner_process=False)
|
|
|
421
461
|
| `gliner_label_map` | `None` | Maps GLiNER labels to NER tags |
|
|
422
462
|
| `gliner_threshold` | `0.4` | GLiNER confidence threshold |
|
|
423
463
|
| `fuzzy_date_score_cutoff` | `85` | Fuzzy matching threshold (0-100) for misspelled months |
|
|
464
|
+
| `custom_pipeline_steps` | `()` | Tuple of `(text: str) -> str` callables appended after all built-in steps |
|
|
424
465
|
|
|
425
466
|
**Language settings**:
|
|
426
467
|
|
|
@@ -466,44 +507,30 @@ Input Text
|
|
|
466
507
|
(lm_text, stat_text, language)
|
|
467
508
|
```
|
|
468
509
|
|
|
469
|
-
Each step is toggled by a `TextCleanerConfig` field. The pipeline is built once at initialization
|
|
470
|
-
|
|
471
|
-
## What's New in v0.4.5
|
|
510
|
+
Each step is toggled by a `TextCleanerConfig` field. The pipeline is built once at initialization; disabled steps are skipped entirely (zero overhead).
|
|
472
511
|
|
|
473
|
-
|
|
512
|
+
## What's New
|
|
474
513
|
|
|
475
|
-
**
|
|
476
|
-
-
|
|
477
|
-
-
|
|
478
|
-
-
|
|
514
|
+
**v0.5.x**
|
|
515
|
+
- `aprocess_batch()`: async batch processing for FastAPI / aiohttp integrations
|
|
516
|
+
- `warmup(languages)`: pre-load NER models at startup to eliminate first-request latency
|
|
517
|
+
- `custom_pipeline_steps`: attach arbitrary `(text: str) -> str` callables after the built-in pipeline
|
|
518
|
+
- French, Portuguese, and Italian NER support via a shared multilingual ONNX session
|
|
519
|
+
- Improved NER sentence boundary detection with abbreviation guard
|
|
479
520
|
|
|
480
|
-
**
|
|
481
|
-
-
|
|
521
|
+
**v0.4.5**
|
|
522
|
+
- Frozen `TextCleanerConfig` dataclass: immutable, thread-safe, per-instance configuration
|
|
523
|
+
- ONNX-first NER inference: torch-free base install (~400 MB models vs ~7 GB)
|
|
524
|
+
- Thread-parallel batch processing via `ThreadPoolExecutor`
|
|
525
|
+
- Five NER backends: `onnx`, `torch`, `gliner`, `ensemble_onnx`, `ensemble_torch`
|
|
482
526
|
- GLiNER zero-shot NER for custom entity types (PRODUCT, EVENT, SKILL, etc.)
|
|
483
527
|
- Ensemble voting across backends for improved recall
|
|
484
|
-
- Lazy per-language model loading
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
-
|
|
490
|
-
- Fuzzy date matching for misspelled months (via rapidfuzz, empirically calibrated threshold)
|
|
491
|
-
- Configurable emoji removal
|
|
492
|
-
- Configurable bracket/brace content removal
|
|
493
|
-
- Smart case folding (preserves NER replacement tokens)
|
|
494
|
-
- Custom stopwords and month names per language
|
|
495
|
-
|
|
496
|
-
**Dependencies**
|
|
497
|
-
- `stop-words` package replaces NLTK (50KB bundled vs 30MB download)
|
|
498
|
-
- PyTorch/Transformers moved to optional `[torch]` extra
|
|
499
|
-
- New optional extras: `[gpu]`, `[fuzzy]`, `[gliner]`, `[gliner2]`, `[all-ner]`
|
|
500
|
-
- Migrated from `setup.py` to `pyproject.toml` (PEP 517)
|
|
501
|
-
|
|
502
|
-
**Quality**
|
|
503
|
-
- Python 3.11–3.13 support
|
|
504
|
-
- `ruff` linter (replaces flake8)
|
|
505
|
-
- hypothesis-based property testing with pytest-timeout
|
|
506
|
-
- Collision-safe NER entity keys
|
|
528
|
+
- Lazy per-language model loading
|
|
529
|
+
- Multilingual date detection and fuzzy date matching
|
|
530
|
+
- Configurable emoji removal, bracket/brace content removal, and smart case folding
|
|
531
|
+
- `stop-words` replaces NLTK (50 KB bundled vs 30 MB download)
|
|
532
|
+
- PyTorch and Transformers moved to optional extras
|
|
533
|
+
- Migrated to `pyproject.toml` (PEP 517), Python 3.11-3.13, ruff linter
|
|
507
534
|
|
|
508
535
|
## Contributing
|
|
509
536
|
|
|
@@ -11,21 +11,25 @@
|
|
|
11
11
|
A comprehensive text cleaning and preprocessing pipeline for machine learning and NLP tasks.
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
|
+
> **Using an AI coding assistant?** This repo includes an [`llms.txt`](https://github.com/rhnfzl/SqueakyCleanText/blob/main/llms.txt) with the full API surface, config reference, and Q&A - optimised for Claude, Cursor, Copilot, and ChatGPT.
|
|
15
|
+
|
|
14
16
|
In the world of machine learning and natural language processing, clean and well-structured text data is crucial for building effective downstream models and managing token limits in language models.
|
|
15
17
|
|
|
16
|
-
SqueakyCleanText simplifies the process by automatically addressing common text issues, ensuring your data is clean and well-structured with minimal effort on your part.
|
|
18
|
+
SqueakyCleanText simplifies the process by automatically addressing common text issues - removing PII, anonymizing named entities (persons, organisations, locations), and ensuring your data is clean and well-structured for language models and classical ML pipelines with minimal effort on your part.
|
|
17
19
|
|
|
18
20
|
### Key Features
|
|
19
21
|
|
|
20
22
|
- **Named Entity Recognition (NER)**:
|
|
21
23
|
- Multi-backend: ONNX (default, torch-free), PyTorch, GLiNER, and ensemble modes
|
|
22
24
|
- Zero-shot custom entities via GLiNER (e.g., PRODUCT, EVENT, SKILL)
|
|
23
|
-
- Multi-language support (English, Dutch, German, Spanish)
|
|
25
|
+
- Multi-language support (English, Dutch, German, Spanish, French, Portuguese, Italian)
|
|
24
26
|
- Ensemble voting across backends for improved accuracy
|
|
25
27
|
- Configurable confidence thresholds
|
|
26
28
|
- Lazy model loading (models load on demand per language)
|
|
27
|
-
-
|
|
29
|
+
- Shared ONNX sessions across same-model languages (~600 MB RAM saved)
|
|
30
|
+
- Automatic text chunking for long documents (CJK/Arabic safe)
|
|
28
31
|
- GPU acceleration support (CUDA for ONNX and PyTorch)
|
|
32
|
+
- Model warm-up API to pre-load on startup
|
|
29
33
|
- **Text Normalization**:
|
|
30
34
|
- Corrects text encoding problems and handles bad Unicode characters
|
|
31
35
|
- Removes or replaces HTML tags and URLs with configurable tokens
|
|
@@ -40,7 +44,7 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
40
44
|
- Smart case folding (preserves NER tokens like `<PERSON>`)
|
|
41
45
|
- **Language Support**:
|
|
42
46
|
- Automatic language detection (English, Dutch, German, Spanish)
|
|
43
|
-
- Language-specific NER models
|
|
47
|
+
- Language-specific NER models; French, Portuguese, Italian via multilingual model
|
|
44
48
|
- Language-aware stopword removal
|
|
45
49
|
- Extensible: add custom languages with stopwords, month names, and NER models
|
|
46
50
|
- **Dual Output Formats**:
|
|
@@ -49,7 +53,9 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
49
53
|
- **Performance**:
|
|
50
54
|
- ONNX Runtime inference (torch-free base install, ~3-5x faster than PyTorch)
|
|
51
55
|
- Thread-parallel batch processing via `ThreadPoolExecutor`
|
|
56
|
+
- Async batch processing (`aprocess_batch`) for FastAPI / aiohttp
|
|
52
57
|
- Lazy model loading (only loads models as needed)
|
|
58
|
+
- Shared ONNX sessions for same-model languages (saves ~600 MB for FR/PT/IT)
|
|
53
59
|
- Memory-efficient processing of large texts
|
|
54
60
|
- GPU acceleration (CUDA) for both ONNX and PyTorch backends
|
|
55
61
|
|
|
@@ -82,7 +88,7 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
82
88
|
pip install SqueakyCleanText
|
|
83
89
|
```
|
|
84
90
|
|
|
85
|
-
The base install uses **ONNX Runtime** for NER inference
|
|
91
|
+
The base install uses **ONNX Runtime** for NER inference - no PyTorch or Transformers required.
|
|
86
92
|
|
|
87
93
|
### Optional Extras
|
|
88
94
|
|
|
@@ -157,7 +163,7 @@ cfg = TextCleanerConfig(
|
|
|
157
163
|
gliner_labels=('person', 'organization', 'location', 'product', 'event'),
|
|
158
164
|
gliner_label_map={
|
|
159
165
|
'person': 'PER', 'organization': 'ORG', 'location': 'LOC',
|
|
160
|
-
# 'product' and 'event' are unmapped
|
|
166
|
+
# 'product' and 'event' are unmapped - they become <PRODUCT>, <EVENT> tokens
|
|
161
167
|
},
|
|
162
168
|
gliner_threshold=0.4,
|
|
163
169
|
)
|
|
@@ -247,7 +253,7 @@ SqueakyCleanText supports five NER backends, selectable via the `ner_backend` co
|
|
|
247
253
|
|
|
248
254
|
| Backend | Description | Dependencies | Best for |
|
|
249
255
|
|---------|-------------|-------------|----------|
|
|
250
|
-
| `onnx` (default) | ONNX Runtime inference with quantized XLM-RoBERTa models | Base install | Production
|
|
256
|
+
| `onnx` (default) | ONNX Runtime inference with quantized XLM-RoBERTa models | Base install | Production: fast, torch-free |
|
|
251
257
|
| `torch` | PyTorch/Transformers pipeline with full XLM-RoBERTa models | `[torch]` extra | Compatibility with existing PyTorch workflows |
|
|
252
258
|
| `gliner` | GLiNER zero-shot NER with custom entity labels | `[gliner]` or `[gliner2]` extra | Custom entity types (PRODUCT, SKILL, EVENT, etc.) |
|
|
253
259
|
| `ensemble_onnx` | ONNX + GLiNER ensemble voting | `[gliner]` extra | Maximum recall with custom entities |
|
|
@@ -261,7 +267,8 @@ SqueakyCleanText supports five NER backends, selectable via the `ner_backend` co
|
|
|
261
267
|
| Dutch | [`rhnfzl/xlm-roberta-large-conll02-dutch-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll02-dutch-onnx) |
|
|
262
268
|
| German | [`rhnfzl/xlm-roberta-large-conll03-german-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll03-german-onnx) |
|
|
263
269
|
| Spanish | [`rhnfzl/xlm-roberta-large-conll02-spanish-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll02-spanish-onnx) |
|
|
264
|
-
|
|
|
270
|
+
| French / Portuguese / Italian | [`rhnfzl/wikineural-multilingual-ner-onnx`](https://huggingface.co/rhnfzl/wikineural-multilingual-ner-onnx) (shared session) |
|
|
271
|
+
| Multilingual (fallback) | [`rhnfzl/wikineural-multilingual-ner-onnx`](https://huggingface.co/rhnfzl/wikineural-multilingual-ner-onnx) |
|
|
265
272
|
|
|
266
273
|
### GLiNER Label Mapping
|
|
267
274
|
|
|
@@ -292,6 +299,28 @@ Processes the input text and returns a tuple containing:
|
|
|
292
299
|
|
|
293
300
|
Processes multiple texts using thread-parallel execution. Each result follows the same format as `process()`.
|
|
294
301
|
|
|
302
|
+
#### `aprocess_batch(texts: List[str], batch_size: int = None) -> List[Tuple[str, Optional[str], Optional[str]]]`
|
|
303
|
+
|
|
304
|
+
Async version of `process_batch` for use with asyncio-based frameworks (FastAPI, aiohttp). Runs the batch in a thread-pool executor so it does not block the event loop:
|
|
305
|
+
|
|
306
|
+
```python
|
|
307
|
+
from sct import TextCleaner
|
|
308
|
+
|
|
309
|
+
cleaner = TextCleaner()
|
|
310
|
+
|
|
311
|
+
# In an async context (FastAPI route, aiohttp handler, etc.)
|
|
312
|
+
results = await cleaner.aprocess_batch(texts)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### `warmup(languages: Optional[List[str]] = None) -> None`
|
|
316
|
+
|
|
317
|
+
Pre-loads NER models to avoid first-request latency. Call once during application startup:
|
|
318
|
+
|
|
319
|
+
```python
|
|
320
|
+
cleaner = TextCleaner()
|
|
321
|
+
cleaner.warmup(['ENGLISH', 'DUTCH']) # or warmup() for all supported languages
|
|
322
|
+
```
|
|
323
|
+
|
|
295
324
|
### `TextCleanerConfig`
|
|
296
325
|
|
|
297
326
|
Immutable (frozen) dataclass. Create modified copies with `dataclasses.replace()`:
|
|
@@ -354,6 +383,7 @@ new_cfg = dataclasses.replace(cfg, check_ner_process=False)
|
|
|
354
383
|
| `ner_backend` | `'onnx'` | Backend: `onnx`, `torch`, `gliner`, `ensemble_onnx`, `ensemble_torch` |
|
|
355
384
|
| `positional_tags` | `('PER', 'LOC', 'ORG', 'MISC')` | Entity types to recognize |
|
|
356
385
|
| `ner_confidence_threshold` | `0.85` | Minimum confidence score |
|
|
386
|
+
| `ner_batch_size` | `8` | Inference batch size (must be >= 1) |
|
|
357
387
|
| `ner_models` | `None` | Language-keyed dict of ONNX model repo IDs |
|
|
358
388
|
| `torch_ner_models` | `None` | Language-keyed dict of PyTorch model repo IDs |
|
|
359
389
|
| `gliner_model` | `None` | GLiNER model ID (required for gliner/ensemble backends) |
|
|
@@ -362,6 +392,7 @@ new_cfg = dataclasses.replace(cfg, check_ner_process=False)
|
|
|
362
392
|
| `gliner_label_map` | `None` | Maps GLiNER labels to NER tags |
|
|
363
393
|
| `gliner_threshold` | `0.4` | GLiNER confidence threshold |
|
|
364
394
|
| `fuzzy_date_score_cutoff` | `85` | Fuzzy matching threshold (0-100) for misspelled months |
|
|
395
|
+
| `custom_pipeline_steps` | `()` | Tuple of `(text: str) -> str` callables appended after all built-in steps |
|
|
365
396
|
|
|
366
397
|
**Language settings**:
|
|
367
398
|
|
|
@@ -407,44 +438,30 @@ Input Text
|
|
|
407
438
|
(lm_text, stat_text, language)
|
|
408
439
|
```
|
|
409
440
|
|
|
410
|
-
Each step is toggled by a `TextCleanerConfig` field. The pipeline is built once at initialization
|
|
411
|
-
|
|
412
|
-
## What's New in v0.4.5
|
|
441
|
+
Each step is toggled by a `TextCleanerConfig` field. The pipeline is built once at initialization; disabled steps are skipped entirely (zero overhead).
|
|
413
442
|
|
|
414
|
-
|
|
443
|
+
## What's New
|
|
415
444
|
|
|
416
|
-
**
|
|
417
|
-
-
|
|
418
|
-
-
|
|
419
|
-
-
|
|
445
|
+
**v0.5.x**
|
|
446
|
+
- `aprocess_batch()`: async batch processing for FastAPI / aiohttp integrations
|
|
447
|
+
- `warmup(languages)`: pre-load NER models at startup to eliminate first-request latency
|
|
448
|
+
- `custom_pipeline_steps`: attach arbitrary `(text: str) -> str` callables after the built-in pipeline
|
|
449
|
+
- French, Portuguese, and Italian NER support via a shared multilingual ONNX session
|
|
450
|
+
- Improved NER sentence boundary detection with abbreviation guard
|
|
420
451
|
|
|
421
|
-
**
|
|
422
|
-
-
|
|
452
|
+
**v0.4.5**
|
|
453
|
+
- Frozen `TextCleanerConfig` dataclass: immutable, thread-safe, per-instance configuration
|
|
454
|
+
- ONNX-first NER inference: torch-free base install (~400 MB models vs ~7 GB)
|
|
455
|
+
- Thread-parallel batch processing via `ThreadPoolExecutor`
|
|
456
|
+
- Five NER backends: `onnx`, `torch`, `gliner`, `ensemble_onnx`, `ensemble_torch`
|
|
423
457
|
- GLiNER zero-shot NER for custom entity types (PRODUCT, EVENT, SKILL, etc.)
|
|
424
458
|
- Ensemble voting across backends for improved recall
|
|
425
|
-
- Lazy per-language model loading
|
|
426
|
-
-
|
|
427
|
-
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
-
|
|
431
|
-
- Fuzzy date matching for misspelled months (via rapidfuzz, empirically calibrated threshold)
|
|
432
|
-
- Configurable emoji removal
|
|
433
|
-
- Configurable bracket/brace content removal
|
|
434
|
-
- Smart case folding (preserves NER replacement tokens)
|
|
435
|
-
- Custom stopwords and month names per language
|
|
436
|
-
|
|
437
|
-
**Dependencies**
|
|
438
|
-
- `stop-words` package replaces NLTK (50KB bundled vs 30MB download)
|
|
439
|
-
- PyTorch/Transformers moved to optional `[torch]` extra
|
|
440
|
-
- New optional extras: `[gpu]`, `[fuzzy]`, `[gliner]`, `[gliner2]`, `[all-ner]`
|
|
441
|
-
- Migrated from `setup.py` to `pyproject.toml` (PEP 517)
|
|
442
|
-
|
|
443
|
-
**Quality**
|
|
444
|
-
- Python 3.11–3.13 support
|
|
445
|
-
- `ruff` linter (replaces flake8)
|
|
446
|
-
- hypothesis-based property testing with pytest-timeout
|
|
447
|
-
- Collision-safe NER entity keys
|
|
459
|
+
- Lazy per-language model loading
|
|
460
|
+
- Multilingual date detection and fuzzy date matching
|
|
461
|
+
- Configurable emoji removal, bracket/brace content removal, and smart case folding
|
|
462
|
+
- `stop-words` replaces NLTK (50 KB bundled vs 30 MB download)
|
|
463
|
+
- PyTorch and Transformers moved to optional extras
|
|
464
|
+
- Migrated to `pyproject.toml` (PEP 517), Python 3.11-3.13, ruff linter
|
|
448
465
|
|
|
449
466
|
## Contributing
|
|
450
467
|
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SqueakyCleanText
|
|
3
|
-
Version: 0.5.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.5.2
|
|
4
|
+
Summary: Text preprocessing & PII anonymization pipeline for NLP/ML: ONNX NER ensemble, language detection, stopword removal, and configurable token replacement.
|
|
5
5
|
Author: Rehan Fazal
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/rhnfzl/SqueakyCleanText
|
|
8
|
-
|
|
8
|
+
Project-URL: Repository, https://github.com/rhnfzl/SqueakyCleanText
|
|
9
|
+
Project-URL: Issues, https://github.com/rhnfzl/SqueakyCleanText/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/rhnfzl/SqueakyCleanText/releases
|
|
11
|
+
Project-URL: llms.txt, https://github.com/rhnfzl/SqueakyCleanText/blob/main/llms.txt
|
|
12
|
+
Keywords: text cleaning,text preprocessing,NLP,natural language processing,named entity recognition,NER,anonymization,PII removal,data cleaning,machine learning,ONNX,language detection
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
18
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Natural Language :: English
|
|
9
21
|
Classifier: Programming Language :: Python :: 3
|
|
10
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
24
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
25
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
26
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
-
Classifier: Topic :: Text Processing
|
|
17
27
|
Requires-Python: >=3.11
|
|
18
28
|
Description-Content-Type: text/markdown
|
|
19
29
|
License-File: LICENSE
|
|
@@ -70,21 +80,25 @@ Dynamic: license-file
|
|
|
70
80
|
A comprehensive text cleaning and preprocessing pipeline for machine learning and NLP tasks.
|
|
71
81
|
</div>
|
|
72
82
|
|
|
83
|
+
> **Using an AI coding assistant?** This repo includes an [`llms.txt`](https://github.com/rhnfzl/SqueakyCleanText/blob/main/llms.txt) with the full API surface, config reference, and Q&A - optimised for Claude, Cursor, Copilot, and ChatGPT.
|
|
84
|
+
|
|
73
85
|
In the world of machine learning and natural language processing, clean and well-structured text data is crucial for building effective downstream models and managing token limits in language models.
|
|
74
86
|
|
|
75
|
-
SqueakyCleanText simplifies the process by automatically addressing common text issues, ensuring your data is clean and well-structured with minimal effort on your part.
|
|
87
|
+
SqueakyCleanText simplifies the process by automatically addressing common text issues - removing PII, anonymizing named entities (persons, organisations, locations), and ensuring your data is clean and well-structured for language models and classical ML pipelines with minimal effort on your part.
|
|
76
88
|
|
|
77
89
|
### Key Features
|
|
78
90
|
|
|
79
91
|
- **Named Entity Recognition (NER)**:
|
|
80
92
|
- Multi-backend: ONNX (default, torch-free), PyTorch, GLiNER, and ensemble modes
|
|
81
93
|
- Zero-shot custom entities via GLiNER (e.g., PRODUCT, EVENT, SKILL)
|
|
82
|
-
- Multi-language support (English, Dutch, German, Spanish)
|
|
94
|
+
- Multi-language support (English, Dutch, German, Spanish, French, Portuguese, Italian)
|
|
83
95
|
- Ensemble voting across backends for improved accuracy
|
|
84
96
|
- Configurable confidence thresholds
|
|
85
97
|
- Lazy model loading (models load on demand per language)
|
|
86
|
-
-
|
|
98
|
+
- Shared ONNX sessions across same-model languages (~600 MB RAM saved)
|
|
99
|
+
- Automatic text chunking for long documents (CJK/Arabic safe)
|
|
87
100
|
- GPU acceleration support (CUDA for ONNX and PyTorch)
|
|
101
|
+
- Model warm-up API to pre-load on startup
|
|
88
102
|
- **Text Normalization**:
|
|
89
103
|
- Corrects text encoding problems and handles bad Unicode characters
|
|
90
104
|
- Removes or replaces HTML tags and URLs with configurable tokens
|
|
@@ -99,7 +113,7 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
99
113
|
- Smart case folding (preserves NER tokens like `<PERSON>`)
|
|
100
114
|
- **Language Support**:
|
|
101
115
|
- Automatic language detection (English, Dutch, German, Spanish)
|
|
102
|
-
- Language-specific NER models
|
|
116
|
+
- Language-specific NER models; French, Portuguese, Italian via multilingual model
|
|
103
117
|
- Language-aware stopword removal
|
|
104
118
|
- Extensible: add custom languages with stopwords, month names, and NER models
|
|
105
119
|
- **Dual Output Formats**:
|
|
@@ -108,7 +122,9 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
108
122
|
- **Performance**:
|
|
109
123
|
- ONNX Runtime inference (torch-free base install, ~3-5x faster than PyTorch)
|
|
110
124
|
- Thread-parallel batch processing via `ThreadPoolExecutor`
|
|
125
|
+
- Async batch processing (`aprocess_batch`) for FastAPI / aiohttp
|
|
111
126
|
- Lazy model loading (only loads models as needed)
|
|
127
|
+
- Shared ONNX sessions for same-model languages (saves ~600 MB for FR/PT/IT)
|
|
112
128
|
- Memory-efficient processing of large texts
|
|
113
129
|
- GPU acceleration (CUDA) for both ONNX and PyTorch backends
|
|
114
130
|
|
|
@@ -141,7 +157,7 @@ SqueakyCleanText simplifies the process by automatically addressing common text
|
|
|
141
157
|
pip install SqueakyCleanText
|
|
142
158
|
```
|
|
143
159
|
|
|
144
|
-
The base install uses **ONNX Runtime** for NER inference
|
|
160
|
+
The base install uses **ONNX Runtime** for NER inference - no PyTorch or Transformers required.
|
|
145
161
|
|
|
146
162
|
### Optional Extras
|
|
147
163
|
|
|
@@ -216,7 +232,7 @@ cfg = TextCleanerConfig(
|
|
|
216
232
|
gliner_labels=('person', 'organization', 'location', 'product', 'event'),
|
|
217
233
|
gliner_label_map={
|
|
218
234
|
'person': 'PER', 'organization': 'ORG', 'location': 'LOC',
|
|
219
|
-
# 'product' and 'event' are unmapped
|
|
235
|
+
# 'product' and 'event' are unmapped - they become <PRODUCT>, <EVENT> tokens
|
|
220
236
|
},
|
|
221
237
|
gliner_threshold=0.4,
|
|
222
238
|
)
|
|
@@ -306,7 +322,7 @@ SqueakyCleanText supports five NER backends, selectable via the `ner_backend` co
|
|
|
306
322
|
|
|
307
323
|
| Backend | Description | Dependencies | Best for |
|
|
308
324
|
|---------|-------------|-------------|----------|
|
|
309
|
-
| `onnx` (default) | ONNX Runtime inference with quantized XLM-RoBERTa models | Base install | Production
|
|
325
|
+
| `onnx` (default) | ONNX Runtime inference with quantized XLM-RoBERTa models | Base install | Production: fast, torch-free |
|
|
310
326
|
| `torch` | PyTorch/Transformers pipeline with full XLM-RoBERTa models | `[torch]` extra | Compatibility with existing PyTorch workflows |
|
|
311
327
|
| `gliner` | GLiNER zero-shot NER with custom entity labels | `[gliner]` or `[gliner2]` extra | Custom entity types (PRODUCT, SKILL, EVENT, etc.) |
|
|
312
328
|
| `ensemble_onnx` | ONNX + GLiNER ensemble voting | `[gliner]` extra | Maximum recall with custom entities |
|
|
@@ -320,7 +336,8 @@ SqueakyCleanText supports five NER backends, selectable via the `ner_backend` co
|
|
|
320
336
|
| Dutch | [`rhnfzl/xlm-roberta-large-conll02-dutch-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll02-dutch-onnx) |
|
|
321
337
|
| German | [`rhnfzl/xlm-roberta-large-conll03-german-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll03-german-onnx) |
|
|
322
338
|
| Spanish | [`rhnfzl/xlm-roberta-large-conll02-spanish-onnx`](https://huggingface.co/rhnfzl/xlm-roberta-large-conll02-spanish-onnx) |
|
|
323
|
-
|
|
|
339
|
+
| French / Portuguese / Italian | [`rhnfzl/wikineural-multilingual-ner-onnx`](https://huggingface.co/rhnfzl/wikineural-multilingual-ner-onnx) (shared session) |
|
|
340
|
+
| Multilingual (fallback) | [`rhnfzl/wikineural-multilingual-ner-onnx`](https://huggingface.co/rhnfzl/wikineural-multilingual-ner-onnx) |
|
|
324
341
|
|
|
325
342
|
### GLiNER Label Mapping
|
|
326
343
|
|
|
@@ -351,6 +368,28 @@ Processes the input text and returns a tuple containing:
|
|
|
351
368
|
|
|
352
369
|
Processes multiple texts using thread-parallel execution. Each result follows the same format as `process()`.
|
|
353
370
|
|
|
371
|
+
#### `aprocess_batch(texts: List[str], batch_size: int = None) -> List[Tuple[str, Optional[str], Optional[str]]]`
|
|
372
|
+
|
|
373
|
+
Async version of `process_batch` for use with asyncio-based frameworks (FastAPI, aiohttp). Runs the batch in a thread-pool executor so it does not block the event loop:
|
|
374
|
+
|
|
375
|
+
```python
|
|
376
|
+
from sct import TextCleaner
|
|
377
|
+
|
|
378
|
+
cleaner = TextCleaner()
|
|
379
|
+
|
|
380
|
+
# In an async context (FastAPI route, aiohttp handler, etc.)
|
|
381
|
+
results = await cleaner.aprocess_batch(texts)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### `warmup(languages: Optional[List[str]] = None) -> None`
|
|
385
|
+
|
|
386
|
+
Pre-loads NER models to avoid first-request latency. Call once during application startup:
|
|
387
|
+
|
|
388
|
+
```python
|
|
389
|
+
cleaner = TextCleaner()
|
|
390
|
+
cleaner.warmup(['ENGLISH', 'DUTCH']) # or warmup() for all supported languages
|
|
391
|
+
```
|
|
392
|
+
|
|
354
393
|
### `TextCleanerConfig`
|
|
355
394
|
|
|
356
395
|
Immutable (frozen) dataclass. Create modified copies with `dataclasses.replace()`:
|
|
@@ -413,6 +452,7 @@ new_cfg = dataclasses.replace(cfg, check_ner_process=False)
|
|
|
413
452
|
| `ner_backend` | `'onnx'` | Backend: `onnx`, `torch`, `gliner`, `ensemble_onnx`, `ensemble_torch` |
|
|
414
453
|
| `positional_tags` | `('PER', 'LOC', 'ORG', 'MISC')` | Entity types to recognize |
|
|
415
454
|
| `ner_confidence_threshold` | `0.85` | Minimum confidence score |
|
|
455
|
+
| `ner_batch_size` | `8` | Inference batch size (must be >= 1) |
|
|
416
456
|
| `ner_models` | `None` | Language-keyed dict of ONNX model repo IDs |
|
|
417
457
|
| `torch_ner_models` | `None` | Language-keyed dict of PyTorch model repo IDs |
|
|
418
458
|
| `gliner_model` | `None` | GLiNER model ID (required for gliner/ensemble backends) |
|
|
@@ -421,6 +461,7 @@ new_cfg = dataclasses.replace(cfg, check_ner_process=False)
|
|
|
421
461
|
| `gliner_label_map` | `None` | Maps GLiNER labels to NER tags |
|
|
422
462
|
| `gliner_threshold` | `0.4` | GLiNER confidence threshold |
|
|
423
463
|
| `fuzzy_date_score_cutoff` | `85` | Fuzzy matching threshold (0-100) for misspelled months |
|
|
464
|
+
| `custom_pipeline_steps` | `()` | Tuple of `(text: str) -> str` callables appended after all built-in steps |
|
|
424
465
|
|
|
425
466
|
**Language settings**:
|
|
426
467
|
|
|
@@ -466,44 +507,30 @@ Input Text
|
|
|
466
507
|
(lm_text, stat_text, language)
|
|
467
508
|
```
|
|
468
509
|
|
|
469
|
-
Each step is toggled by a `TextCleanerConfig` field. The pipeline is built once at initialization
|
|
470
|
-
|
|
471
|
-
## What's New in v0.4.5
|
|
510
|
+
Each step is toggled by a `TextCleanerConfig` field. The pipeline is built once at initialization; disabled steps are skipped entirely (zero overhead).
|
|
472
511
|
|
|
473
|
-
|
|
512
|
+
## What's New
|
|
474
513
|
|
|
475
|
-
**
|
|
476
|
-
-
|
|
477
|
-
-
|
|
478
|
-
-
|
|
514
|
+
**v0.5.x**
|
|
515
|
+
- `aprocess_batch()`: async batch processing for FastAPI / aiohttp integrations
|
|
516
|
+
- `warmup(languages)`: pre-load NER models at startup to eliminate first-request latency
|
|
517
|
+
- `custom_pipeline_steps`: attach arbitrary `(text: str) -> str` callables after the built-in pipeline
|
|
518
|
+
- French, Portuguese, and Italian NER support via a shared multilingual ONNX session
|
|
519
|
+
- Improved NER sentence boundary detection with abbreviation guard
|
|
479
520
|
|
|
480
|
-
**
|
|
481
|
-
-
|
|
521
|
+
**v0.4.5**
|
|
522
|
+
- Frozen `TextCleanerConfig` dataclass: immutable, thread-safe, per-instance configuration
|
|
523
|
+
- ONNX-first NER inference: torch-free base install (~400 MB models vs ~7 GB)
|
|
524
|
+
- Thread-parallel batch processing via `ThreadPoolExecutor`
|
|
525
|
+
- Five NER backends: `onnx`, `torch`, `gliner`, `ensemble_onnx`, `ensemble_torch`
|
|
482
526
|
- GLiNER zero-shot NER for custom entity types (PRODUCT, EVENT, SKILL, etc.)
|
|
483
527
|
- Ensemble voting across backends for improved recall
|
|
484
|
-
- Lazy per-language model loading
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
-
|
|
490
|
-
- Fuzzy date matching for misspelled months (via rapidfuzz, empirically calibrated threshold)
|
|
491
|
-
- Configurable emoji removal
|
|
492
|
-
- Configurable bracket/brace content removal
|
|
493
|
-
- Smart case folding (preserves NER replacement tokens)
|
|
494
|
-
- Custom stopwords and month names per language
|
|
495
|
-
|
|
496
|
-
**Dependencies**
|
|
497
|
-
- `stop-words` package replaces NLTK (50KB bundled vs 30MB download)
|
|
498
|
-
- PyTorch/Transformers moved to optional `[torch]` extra
|
|
499
|
-
- New optional extras: `[gpu]`, `[fuzzy]`, `[gliner]`, `[gliner2]`, `[all-ner]`
|
|
500
|
-
- Migrated from `setup.py` to `pyproject.toml` (PEP 517)
|
|
501
|
-
|
|
502
|
-
**Quality**
|
|
503
|
-
- Python 3.11–3.13 support
|
|
504
|
-
- `ruff` linter (replaces flake8)
|
|
505
|
-
- hypothesis-based property testing with pytest-timeout
|
|
506
|
-
- Collision-safe NER entity keys
|
|
528
|
+
- Lazy per-language model loading
|
|
529
|
+
- Multilingual date detection and fuzzy date matching
|
|
530
|
+
- Configurable emoji removal, bracket/brace content removal, and smart case folding
|
|
531
|
+
- `stop-words` replaces NLTK (50 KB bundled vs 30 MB download)
|
|
532
|
+
- PyTorch and Transformers moved to optional extras
|
|
533
|
+
- Migrated to `pyproject.toml` (PEP 517), Python 3.11-3.13, ruff linter
|
|
507
534
|
|
|
508
535
|
## Contributing
|
|
509
536
|
|
|
@@ -4,22 +4,32 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "SqueakyCleanText"
|
|
7
|
-
|
|
8
|
-
description = "
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Text preprocessing & PII anonymization pipeline for NLP/ML: ONNX NER ensemble, language detection, stopword removal, and configurable token replacement."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
11
11
|
authors = [{name = "Rehan Fazal"}]
|
|
12
12
|
requires-python = ">=3.11"
|
|
13
|
-
keywords = [
|
|
13
|
+
keywords = [
|
|
14
|
+
"text cleaning", "text preprocessing", "NLP", "natural language processing",
|
|
15
|
+
"named entity recognition", "NER", "anonymization", "PII removal",
|
|
16
|
+
"data cleaning", "machine learning", "ONNX", "language detection",
|
|
17
|
+
]
|
|
14
18
|
classifiers = [
|
|
19
|
+
"Development Status :: 5 - Production/Stable",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
24
|
+
"Topic :: Text Processing :: Linguistic",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Natural Language :: English",
|
|
15
27
|
"Programming Language :: Python :: 3",
|
|
16
28
|
"Programming Language :: Python :: 3.11",
|
|
17
29
|
"Programming Language :: Python :: 3.12",
|
|
18
30
|
"Programming Language :: Python :: 3.13",
|
|
19
31
|
"License :: OSI Approved :: MIT License",
|
|
20
32
|
"Operating System :: OS Independent",
|
|
21
|
-
"Topic :: Software Development :: Libraries",
|
|
22
|
-
"Topic :: Text Processing",
|
|
23
33
|
]
|
|
24
34
|
dependencies = [
|
|
25
35
|
"lingua-language-detector>=2.0.2",
|
|
@@ -38,6 +48,10 @@ dependencies = [
|
|
|
38
48
|
|
|
39
49
|
[project.urls]
|
|
40
50
|
Homepage = "https://github.com/rhnfzl/SqueakyCleanText"
|
|
51
|
+
Repository = "https://github.com/rhnfzl/SqueakyCleanText"
|
|
52
|
+
Issues = "https://github.com/rhnfzl/SqueakyCleanText/issues"
|
|
53
|
+
Changelog = "https://github.com/rhnfzl/SqueakyCleanText/releases"
|
|
54
|
+
"llms.txt" = "https://github.com/rhnfzl/SqueakyCleanText/blob/main/llms.txt"
|
|
41
55
|
|
|
42
56
|
[project.optional-dependencies]
|
|
43
57
|
gpu = [
|
|
@@ -75,6 +89,9 @@ test = [
|
|
|
75
89
|
"pytest-cov>=4.1",
|
|
76
90
|
]
|
|
77
91
|
|
|
92
|
+
[tool.setuptools.dynamic]
|
|
93
|
+
version = {attr = "sct.__version__"}
|
|
94
|
+
|
|
78
95
|
[tool.setuptools.packages.find]
|
|
79
96
|
include = ["sct*"]
|
|
80
97
|
exclude = ["tests*"]
|
|
File without changes
|
|
File without changes
|
{squeakycleantext-0.5.0 → squeakycleantext-0.5.2}/SqueakyCleanText.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|