catchfly 0.0.1__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.
- catchfly-0.0.1/.gitignore +207 -0
- catchfly-0.0.1/LICENSE +21 -0
- catchfly-0.0.1/PKG-INFO +195 -0
- catchfly-0.0.1/README.md +169 -0
- catchfly-0.0.1/pyproject.toml +43 -0
- catchfly-0.0.1/src/catchfly/__init__.py +8 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
catchfly-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 amichalski2
|
|
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.
|
catchfly-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: catchfly
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: From chaos to categories. Schema discovery + term normalization for unstructured text data.
|
|
5
|
+
Project-URL: Homepage, https://github.com/silene-systems/catchfly
|
|
6
|
+
Project-URL: Documentation, https://github.com/silene-systems/catchfly
|
|
7
|
+
Project-URL: Repository, https://github.com/silene-systems/catchfly
|
|
8
|
+
Project-URL: Issues, https://github.com/silene-systems/catchfly/issues
|
|
9
|
+
Author-email: Adrian Michalski <adrian@silene.systems>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: clustering,deduplication,llm,nlp,normalization,rare-diseases,schema-discovery,text-classification
|
|
13
|
+
Classifier: Development Status :: 1 - Planning
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<h1 align="center">catchfly</h1>
|
|
29
|
+
<p align="center"><strong>From chaos to categories.</strong></p>
|
|
30
|
+
<p align="center">Schema discovery + term normalization for unstructured text data.</p>
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://pypi.org/project/catchfly/"><img src="https://img.shields.io/pypi/v/catchfly?color=6B2D8B" alt="PyPI"></a>
|
|
33
|
+
<a href="https://github.com/silene-systems/catchfly/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License"></a>
|
|
34
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/pypi/pyversions/catchfly" alt="Python"></a>
|
|
35
|
+
</p>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
> *Named after [Silene](https://en.wikipedia.org/wiki/Silene) (catchfly) — plants that secrete a sticky substance to capture insects. Catchfly captures scattered terms and groups them into canonical categories.*
|
|
41
|
+
>
|
|
42
|
+
> *Part of the [Silene Systems](https://silene.systems) ecosystem for rare disease research.*
|
|
43
|
+
|
|
44
|
+
## The problem
|
|
45
|
+
|
|
46
|
+
You extracted 3,000 mentions from 200 scientific papers. Or an LLM classified 3 million emails into 4,000 labels. Now you have:
|
|
47
|
+
|
|
48
|
+
- **No schema** — you don't know what categories should exist
|
|
49
|
+
- **Duplicates everywhere** — "miglustat" and "Zavesca" are the same drug
|
|
50
|
+
- **Ambiguous boundaries** — is "cognitive decline" the same as "cognitive impairment"?
|
|
51
|
+
- **Related but distinct entities** — "ALT" and "AST" are similar but clinically different
|
|
52
|
+
|
|
53
|
+
No existing tool does both **schema discovery** and **term normalization** as a composable Python library.
|
|
54
|
+
|
|
55
|
+
## What catchfly does
|
|
56
|
+
|
|
57
|
+
**Two operations, one pipeline:**
|
|
58
|
+
|
|
59
|
+
**Discover** — *"What categories exist in my data?"*
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from catchfly import Resolver
|
|
63
|
+
|
|
64
|
+
resolver = Resolver(embed_provider="gemini", llm_provider="openai/gpt-5.4")
|
|
65
|
+
|
|
66
|
+
schema = resolver.discover(
|
|
67
|
+
mentions=["miglustat", "splenomegaly", "ALT: 120", "ataxia", ...],
|
|
68
|
+
contexts={"miglustat": ["Patient received miglustat 200mg daily"], ...},
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# schema.categories → ["Treatments", "Symptoms", "Lab Values", ...]
|
|
72
|
+
# schema.examples → {"Treatments": ["miglustat", "arimoclomol"], ...}
|
|
73
|
+
|
|
74
|
+
schema.rename("Lab Values", "Laboratory Findings")
|
|
75
|
+
schema.merge("Symptoms", "Clinical Signs")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Normalize** — *"Which terms belong where, and which are synonyms?"*
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
result = resolver.normalize(
|
|
82
|
+
mentions=all_mentions,
|
|
83
|
+
schema=schema,
|
|
84
|
+
contexts=contexts,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# result.groups → [NormGroup(canonical="miglustat", members=["Zavesca", "NB-DNJ"])]
|
|
88
|
+
# result.ambiguous → [AmbiguousPair("cognitive decline", "cognitive impairment")]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Or all-in-one:**
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
result = resolver.resolve(mentions, contexts=contexts)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Self-improving prompts
|
|
98
|
+
|
|
99
|
+
Give catchfly 20–50 labeled examples and it optimizes its own prompts for your domain. Inspired by [GEPA](https://github.com/gepa-ai/gepa), implemented from scratch with zero external dependencies.
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
optimized = resolver.optimize(
|
|
103
|
+
mentions=mentions,
|
|
104
|
+
contexts=contexts,
|
|
105
|
+
ground_truth={"miglustat": "miglustat", "Zavesca": "miglustat", "ALT": "ALT", "AST": "AST"},
|
|
106
|
+
iterations=20, # ~$1–2, ~15 min
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
result = optimized.resolve(new_mentions) # 20–30% better accuracy on your domain
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## How it works
|
|
113
|
+
|
|
114
|
+
Four components, composable as a pipeline:
|
|
115
|
+
|
|
116
|
+
| Component | What it does | Cost |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| **EmbeddingSimilarity** | Pre-filter: finds candidate pairs via cosine similarity | Embedding API only |
|
|
119
|
+
| **LLMGrouper** | Core engine: LLM analyzes clusters, proposes categories/synonyms with 4-way relation typing (synonym / hierarchy / related / distinct) | LLM API |
|
|
120
|
+
| **LLMClassifier** | Propagation: assigns remaining mentions to approved categories via few-shot classification | LLM API |
|
|
121
|
+
| **UserSeeded** | User guidance: seed mappings override and anchor discovery + normalization | Embedding only |
|
|
122
|
+
|
|
123
|
+
## Tiered quality
|
|
124
|
+
|
|
125
|
+
| Tier | What runs | Cost / 1K mentions | Accuracy | Best for |
|
|
126
|
+
|---|---|---|---|---|
|
|
127
|
+
| **Tier 1** (free) | Embedding only | $0 (local models) | 60–70% | Exploration |
|
|
128
|
+
| **Tier 2** (standard) | Embedding + LLM | $0.15–0.50 | 82–90% | Production |
|
|
129
|
+
| **Tier 3** (optimized) | Tier 2 + optimize() | $1–3 one-time | 90–95%+ | Systematic reviews |
|
|
130
|
+
|
|
131
|
+
## Use cases
|
|
132
|
+
|
|
133
|
+
- **Medical literature** — normalize symptoms, drugs, genetic variants from systematic reviews
|
|
134
|
+
- **Email categorization** — collapse 4,000 LLM-generated labels into 150 clean groups
|
|
135
|
+
- **E-commerce tags** — build taxonomy from 50,000 user-generated product tags
|
|
136
|
+
- **Any domain** — if you have messy text labels, catchfly cleans them up
|
|
137
|
+
|
|
138
|
+
## Provider support
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
# Embeddings
|
|
142
|
+
Resolver(embed_provider="gemini") # Google Gemini Embedding 2
|
|
143
|
+
Resolver(embed_provider="openai") # OpenAI text-embedding-3
|
|
144
|
+
Resolver(embed_provider="local") # sentence-transformers (offline, free)
|
|
145
|
+
Resolver(embed_provider=my_function) # any callable
|
|
146
|
+
|
|
147
|
+
# LLM
|
|
148
|
+
Resolver(llm_provider="openai/gpt-5.4")
|
|
149
|
+
Resolver(llm_provider="gemini/flash")
|
|
150
|
+
Resolver(llm_provider=my_function) # any callable
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Evaluation
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
ground_truth = {"miglustat": "miglustat", "Zavesca": "miglustat", "ALT": "ALT", "AST": "AST"}
|
|
157
|
+
metrics = resolver.evaluate(result, ground_truth)
|
|
158
|
+
# → precision, recall, false_merges, missed_merges, category_accuracy
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Installation
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pip install catchfly
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
> **v0.0.1 is a name reservation.** Active development underway. First functional release (v0.1.0) expected Q2 2026.
|
|
168
|
+
|
|
169
|
+
## Part of the Silene ecosystem
|
|
170
|
+
|
|
171
|
+
| Project | What it is |
|
|
172
|
+
|---|---|
|
|
173
|
+
| **[Silene Systems](https://silene.systems)** | Computational phenotyping platform for rare diseases |
|
|
174
|
+
| **Campion** | Agentic batch literature extraction platform (SaaS) |
|
|
175
|
+
| **catchfly** | Schema discovery + term normalization library (open source, this repo) |
|
|
176
|
+
|
|
177
|
+
> *[Silene tomentosa](https://en.wikipedia.org/wiki/Silene_tomentosa) (Gibraltar campion) is one of the rarest plants in the world — thought extinct in 1992, rediscovered in 1994 on the Rock of Gibraltar. Like rare diseases, it hides in plain sight, waiting for someone to look carefully enough.*
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
Apache-2.0
|
|
182
|
+
|
|
183
|
+
## Citation
|
|
184
|
+
|
|
185
|
+
If you use catchfly in academic work:
|
|
186
|
+
|
|
187
|
+
```bibtex
|
|
188
|
+
@software{catchfly2026,
|
|
189
|
+
author = {Michalski, Adrian},
|
|
190
|
+
title = {catchfly: Schema discovery and category normalization for unstructured text data},
|
|
191
|
+
year = {2026},
|
|
192
|
+
url = {https://github.com/silene-systems/catchfly},
|
|
193
|
+
license = {Apache-2.0}
|
|
194
|
+
}
|
|
195
|
+
``
|
catchfly-0.0.1/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">catchfly</h1>
|
|
3
|
+
<p align="center"><strong>From chaos to categories.</strong></p>
|
|
4
|
+
<p align="center">Schema discovery + term normalization for unstructured text data.</p>
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://pypi.org/project/catchfly/"><img src="https://img.shields.io/pypi/v/catchfly?color=6B2D8B" alt="PyPI"></a>
|
|
7
|
+
<a href="https://github.com/silene-systems/catchfly/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License"></a>
|
|
8
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/pypi/pyversions/catchfly" alt="Python"></a>
|
|
9
|
+
</p>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
> *Named after [Silene](https://en.wikipedia.org/wiki/Silene) (catchfly) — plants that secrete a sticky substance to capture insects. Catchfly captures scattered terms and groups them into canonical categories.*
|
|
15
|
+
>
|
|
16
|
+
> *Part of the [Silene Systems](https://silene.systems) ecosystem for rare disease research.*
|
|
17
|
+
|
|
18
|
+
## The problem
|
|
19
|
+
|
|
20
|
+
You extracted 3,000 mentions from 200 scientific papers. Or an LLM classified 3 million emails into 4,000 labels. Now you have:
|
|
21
|
+
|
|
22
|
+
- **No schema** — you don't know what categories should exist
|
|
23
|
+
- **Duplicates everywhere** — "miglustat" and "Zavesca" are the same drug
|
|
24
|
+
- **Ambiguous boundaries** — is "cognitive decline" the same as "cognitive impairment"?
|
|
25
|
+
- **Related but distinct entities** — "ALT" and "AST" are similar but clinically different
|
|
26
|
+
|
|
27
|
+
No existing tool does both **schema discovery** and **term normalization** as a composable Python library.
|
|
28
|
+
|
|
29
|
+
## What catchfly does
|
|
30
|
+
|
|
31
|
+
**Two operations, one pipeline:**
|
|
32
|
+
|
|
33
|
+
**Discover** — *"What categories exist in my data?"*
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from catchfly import Resolver
|
|
37
|
+
|
|
38
|
+
resolver = Resolver(embed_provider="gemini", llm_provider="openai/gpt-5.4")
|
|
39
|
+
|
|
40
|
+
schema = resolver.discover(
|
|
41
|
+
mentions=["miglustat", "splenomegaly", "ALT: 120", "ataxia", ...],
|
|
42
|
+
contexts={"miglustat": ["Patient received miglustat 200mg daily"], ...},
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# schema.categories → ["Treatments", "Symptoms", "Lab Values", ...]
|
|
46
|
+
# schema.examples → {"Treatments": ["miglustat", "arimoclomol"], ...}
|
|
47
|
+
|
|
48
|
+
schema.rename("Lab Values", "Laboratory Findings")
|
|
49
|
+
schema.merge("Symptoms", "Clinical Signs")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Normalize** — *"Which terms belong where, and which are synonyms?"*
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
result = resolver.normalize(
|
|
56
|
+
mentions=all_mentions,
|
|
57
|
+
schema=schema,
|
|
58
|
+
contexts=contexts,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# result.groups → [NormGroup(canonical="miglustat", members=["Zavesca", "NB-DNJ"])]
|
|
62
|
+
# result.ambiguous → [AmbiguousPair("cognitive decline", "cognitive impairment")]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Or all-in-one:**
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
result = resolver.resolve(mentions, contexts=contexts)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Self-improving prompts
|
|
72
|
+
|
|
73
|
+
Give catchfly 20–50 labeled examples and it optimizes its own prompts for your domain. Inspired by [GEPA](https://github.com/gepa-ai/gepa), implemented from scratch with zero external dependencies.
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
optimized = resolver.optimize(
|
|
77
|
+
mentions=mentions,
|
|
78
|
+
contexts=contexts,
|
|
79
|
+
ground_truth={"miglustat": "miglustat", "Zavesca": "miglustat", "ALT": "ALT", "AST": "AST"},
|
|
80
|
+
iterations=20, # ~$1–2, ~15 min
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
result = optimized.resolve(new_mentions) # 20–30% better accuracy on your domain
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## How it works
|
|
87
|
+
|
|
88
|
+
Four components, composable as a pipeline:
|
|
89
|
+
|
|
90
|
+
| Component | What it does | Cost |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| **EmbeddingSimilarity** | Pre-filter: finds candidate pairs via cosine similarity | Embedding API only |
|
|
93
|
+
| **LLMGrouper** | Core engine: LLM analyzes clusters, proposes categories/synonyms with 4-way relation typing (synonym / hierarchy / related / distinct) | LLM API |
|
|
94
|
+
| **LLMClassifier** | Propagation: assigns remaining mentions to approved categories via few-shot classification | LLM API |
|
|
95
|
+
| **UserSeeded** | User guidance: seed mappings override and anchor discovery + normalization | Embedding only |
|
|
96
|
+
|
|
97
|
+
## Tiered quality
|
|
98
|
+
|
|
99
|
+
| Tier | What runs | Cost / 1K mentions | Accuracy | Best for |
|
|
100
|
+
|---|---|---|---|---|
|
|
101
|
+
| **Tier 1** (free) | Embedding only | $0 (local models) | 60–70% | Exploration |
|
|
102
|
+
| **Tier 2** (standard) | Embedding + LLM | $0.15–0.50 | 82–90% | Production |
|
|
103
|
+
| **Tier 3** (optimized) | Tier 2 + optimize() | $1–3 one-time | 90–95%+ | Systematic reviews |
|
|
104
|
+
|
|
105
|
+
## Use cases
|
|
106
|
+
|
|
107
|
+
- **Medical literature** — normalize symptoms, drugs, genetic variants from systematic reviews
|
|
108
|
+
- **Email categorization** — collapse 4,000 LLM-generated labels into 150 clean groups
|
|
109
|
+
- **E-commerce tags** — build taxonomy from 50,000 user-generated product tags
|
|
110
|
+
- **Any domain** — if you have messy text labels, catchfly cleans them up
|
|
111
|
+
|
|
112
|
+
## Provider support
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# Embeddings
|
|
116
|
+
Resolver(embed_provider="gemini") # Google Gemini Embedding 2
|
|
117
|
+
Resolver(embed_provider="openai") # OpenAI text-embedding-3
|
|
118
|
+
Resolver(embed_provider="local") # sentence-transformers (offline, free)
|
|
119
|
+
Resolver(embed_provider=my_function) # any callable
|
|
120
|
+
|
|
121
|
+
# LLM
|
|
122
|
+
Resolver(llm_provider="openai/gpt-5.4")
|
|
123
|
+
Resolver(llm_provider="gemini/flash")
|
|
124
|
+
Resolver(llm_provider=my_function) # any callable
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Evaluation
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
ground_truth = {"miglustat": "miglustat", "Zavesca": "miglustat", "ALT": "ALT", "AST": "AST"}
|
|
131
|
+
metrics = resolver.evaluate(result, ground_truth)
|
|
132
|
+
# → precision, recall, false_merges, missed_merges, category_accuracy
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Installation
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pip install catchfly
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
> **v0.0.1 is a name reservation.** Active development underway. First functional release (v0.1.0) expected Q2 2026.
|
|
142
|
+
|
|
143
|
+
## Part of the Silene ecosystem
|
|
144
|
+
|
|
145
|
+
| Project | What it is |
|
|
146
|
+
|---|---|
|
|
147
|
+
| **[Silene Systems](https://silene.systems)** | Computational phenotyping platform for rare diseases |
|
|
148
|
+
| **Campion** | Agentic batch literature extraction platform (SaaS) |
|
|
149
|
+
| **catchfly** | Schema discovery + term normalization library (open source, this repo) |
|
|
150
|
+
|
|
151
|
+
> *[Silene tomentosa](https://en.wikipedia.org/wiki/Silene_tomentosa) (Gibraltar campion) is one of the rarest plants in the world — thought extinct in 1992, rediscovered in 1994 on the Rock of Gibraltar. Like rare diseases, it hides in plain sight, waiting for someone to look carefully enough.*
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
Apache-2.0
|
|
156
|
+
|
|
157
|
+
## Citation
|
|
158
|
+
|
|
159
|
+
If you use catchfly in academic work:
|
|
160
|
+
|
|
161
|
+
```bibtex
|
|
162
|
+
@software{catchfly2026,
|
|
163
|
+
author = {Michalski, Adrian},
|
|
164
|
+
title = {catchfly: Schema discovery and category normalization for unstructured text data},
|
|
165
|
+
year = {2026},
|
|
166
|
+
url = {https://github.com/silene-systems/catchfly},
|
|
167
|
+
license = {Apache-2.0}
|
|
168
|
+
}
|
|
169
|
+
``
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "catchfly"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "From chaos to categories. Schema discovery + term normalization for unstructured text data."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Adrian Michalski", email = "adrian@silene.systems" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"normalization",
|
|
17
|
+
"schema-discovery",
|
|
18
|
+
"clustering",
|
|
19
|
+
"llm",
|
|
20
|
+
"nlp",
|
|
21
|
+
"deduplication",
|
|
22
|
+
"text-classification",
|
|
23
|
+
"rare-diseases",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 1 - Planning",
|
|
27
|
+
"Intended Audience :: Science/Research",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"License :: OSI Approved :: Apache Software License",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
36
|
+
"Topic :: Text Processing :: Linguistic",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/silene-systems/catchfly"
|
|
41
|
+
Documentation = "https://github.com/silene-systems/catchfly"
|
|
42
|
+
Repository = "https://github.com/silene-systems/catchfly"
|
|
43
|
+
Issues = "https://github.com/silene-systems/catchfly/issues"
|