Skip to content

Commit 26c9007

Browse files
author
alex-omophub
committed
v1.4.0 release
1 parent 52a5113 commit 26c9007

4 files changed

Lines changed: 93 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.4.0] - 2026-02-23
9+
10+
### Added
11+
12+
- **Semantic search** (`search.semantic()`, `search.semantic_iter()`): Natural language concept search using neural embeddings. Search for clinical intent like "high blood sugar levels" to find diabetes-related concepts. Supports filtering by vocabulary, domain, standard concept, concept class, and minimum similarity threshold. `semantic_iter()` provides automatic pagination.
13+
- **Similarity search** (`search.similar()`): Find concepts similar to a reference concept ID, concept name, or natural language query. Three algorithm options: `'semantic'` (neural embeddings), `'lexical'` (string matching), and `'hybrid'` (combined). Configurable similarity threshold with optional detailed scores and explanations.
14+
815
## [1.3.1] - 2026-01-24
916

1017
### Fixed
@@ -83,7 +90,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8390
- Full type hints and PEP 561 compliance
8491
- HTTP/2 support via httpx
8592

86-
[Unreleased]: https://github.com/omopHub/omophub-python/compare/v1.3.1...HEAD
93+
[Unreleased]: https://github.com/omopHub/omophub-python/compare/v1.4.0...HEAD
94+
[1.4.0]: https://github.com/omopHub/omophub-python/compare/v1.3.1...v1.4.0
8795
[1.3.1]: https://github.com/omopHub/omophub-python/compare/v1.3.0...v1.3.1
8896
[1.3.0]: https://github.com/omopHub/omophub-python/compare/v1.2.0...v1.3.0
8997
[1.2.0]: https://github.com/omopHub/omophub-python/compare/v0.1.0...v1.2.0

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ for result in client.search.semantic_iter("chronic kidney disease", page_size=50
8181
print(f"{result['concept_id']}: {result['concept_name']}")
8282
```
8383

84+
### Similarity Search
85+
86+
Find concepts similar to a known concept or natural language query:
87+
88+
```python
89+
# Find concepts similar to a known concept
90+
results = client.search.similar(concept_id=201826, algorithm="hybrid")
91+
for r in results["results"]:
92+
print(f"{r['concept_name']} (score: {r['similarity_score']:.2f})")
93+
94+
# Find similar concepts using a natural language query
95+
results = client.search.similar(
96+
query="medications for high blood pressure",
97+
algorithm="semantic",
98+
similarity_threshold=0.6,
99+
vocabulary_ids=["RxNorm"],
100+
include_scores=True,
101+
)
102+
```
103+
84104
## Async Support
85105

86106
```python
@@ -153,7 +173,7 @@ suggestions = client.concepts.suggest("diab", vocabulary_ids=["SNOMED"], page_si
153173
| Resource | Description | Key Methods |
154174
|----------|-------------|-------------|
155175
| `concepts` | Concept lookup and batch operations | `get()`, `get_by_code()`, `batch()`, `suggest()` |
156-
| `search` | Full-text and semantic search | `basic()`, `advanced()`, `semantic()`, `semantic_iter()`, `fuzzy()` |
176+
| `search` | Full-text and semantic search | `basic()`, `advanced()`, `semantic()`, `semantic_iter()`, `similar()`, `fuzzy()` |
157177
| `hierarchy` | Navigate concept relationships | `ancestors()`, `descendants()` |
158178
| `mappings` | Cross-vocabulary mappings | `get()`, `map()` |
159179
| `vocabularies` | Vocabulary metadata | `list()`, `get()`, `stats()` |

examples/search_concepts.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,68 @@ def pagination_example() -> None:
8080
print(f" ... and {count - 3} more concepts shown (demo limited to {count})")
8181

8282

83+
def semantic_search() -> None:
84+
"""Demonstrate semantic search using neural embeddings."""
85+
print("\n=== Semantic Search ===")
86+
87+
# Natural language search - understands clinical intent
88+
results = client.search.semantic("high blood sugar levels")
89+
for r in results["results"][:3]:
90+
print(f" {r['concept_name']} (similarity: {r['similarity_score']:.2f})")
91+
92+
# Filtered semantic search with minimum threshold
93+
results = client.search.semantic(
94+
"heart attack",
95+
vocabulary_ids=["SNOMED"],
96+
domain_ids=["Condition"],
97+
threshold=0.5,
98+
)
99+
print(f" Found {len(results['results'])} SNOMED conditions for 'heart attack'")
100+
101+
102+
def semantic_pagination() -> None:
103+
"""Demonstrate auto-pagination with semantic_iter."""
104+
print("\n=== Semantic Pagination ===")
105+
106+
count = 0
107+
for result in client.search.semantic_iter("chronic kidney disease", page_size=20):
108+
count += 1
109+
if count <= 3:
110+
print(f" {result['concept_id']}: {result['concept_name']}")
111+
if count >= 50: # Limit for demo
112+
break
113+
114+
if count > 3:
115+
print(f" ... and {count - 3} more results (demo limited to {count})")
116+
117+
118+
def similarity_search() -> None:
119+
"""Demonstrate similarity search."""
120+
print("\n=== Similarity Search ===")
121+
122+
# Find concepts similar to Type 2 diabetes mellitus (concept_id=201826)
123+
results = client.search.similar(concept_id=201826, algorithm="hybrid")
124+
print("Concepts similar to 'Type 2 diabetes mellitus':")
125+
for r in results["results"][:5]:
126+
print(f" {r['concept_name']} (score: {r['similarity_score']:.2f})")
127+
128+
# Find similar using a natural language query with semantic algorithm
129+
results = client.search.similar(
130+
query="medications for high blood pressure",
131+
algorithm="semantic",
132+
similarity_threshold=0.6,
133+
vocabulary_ids=["RxNorm"],
134+
include_scores=True,
135+
)
136+
print(f"\n Found {len(results['results'])} similar RxNorm concepts")
137+
138+
83139
if __name__ == "__main__":
84140
basic_search()
85141
filtered_search()
86142
fuzzy_search()
87143
autocomplete_example()
88144
pagination_example()
145+
semantic_search()
146+
semantic_pagination()
147+
similarity_search()

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
55
[project]
66
name = "omophub"
77
dynamic = ["version"]
8-
description = "Python SDK for OMOPHub - Medical Vocabulary API"
8+
description = "Python SDK for OMOPHub - Medical Vocabulary API with semantic search"
99
readme = "README.md"
1010
license = "MIT"
1111
requires-python = ">=3.10"
@@ -27,6 +27,9 @@ keywords = [
2727
"terminology",
2828
"api",
2929
"sdk",
30+
"semantic-search",
31+
"embeddings",
32+
"nlp",
3033
]
3134
classifiers = [
3235
"Development Status :: 4 - Beta",

0 commit comments

Comments
 (0)