A library for fuzzy matching terms in text with corresponding codes.
Project description
Text-to-AthenaCode
This library simply receives a input text and matches possible terms against a dictionary of terms that contain their associated Athena codes. For instance:
For the terms to code dictionary:
"Male": 8507,
"Female": 8532,
"Angiomyxoma": 4239956,
and input text,
- "Query for all female patients diagnosed with angiomyxoma"
the library returns:
- "Query for all 8532 patients diagnosed with 4239956"
Consider that the dictionary terms can be obtained from anywhere, in this case we are using it for the IDEA4RC project's datamodel.
Methods
Fuzy string matching.
How to use it
- Just install requirements (check end of file)
- Run
DM_codes_extractionfor obtaining the term_to_code.json. This step can be replaced for any other dictionaries. - Run
demo.pyfor a demo
from term_matcher import load_term_to_code, match_terms
# Load term-to-code mappings
term_to_code = load_term_to_code("dictionaries/term_to_code.json") # if working with term to code
# Input text
text = "The patient with angiomyxoma and carcinoma was diagnosed."
# Match terms to codes
matched_codes, matched_terms = match_terms(text, term_to_code, threshold=50)
# Output matched codes
print("Matched Codes:", matched_codes)
# Optionally, output matched terms for debugging
print("Matched Terms:", matched_terms)
Output:
Matched Codes: [4239956, 4233949, 4175678, 4164740, 4206785, 4224593, 37156145, 4241843, 4029680, 4022895]
Matched Terms: ['Angiomyxoma', 'Verrucous carcinoma', 'Giant cell carcinoma', 'Acinar cell carcinoma', 'Schneiderian carcinoma', 'Juvenile carcinoma of the breast', 'Squamous cell carcinoma', 'Adenosquamous carcinoma', 'Myoepithelial carcinoma', 'Adenoid cystic carcinoma']
Improvements
- Synonyms
- Multi-term matching
- ElasticSearch for bigger size dictionaries (basically full Athena Concepts).
Installation as package
pip install -e .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file term_matcher-0.2.tar.gz.
File metadata
- Download URL: term_matcher-0.2.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c263fb6253721a3043488c47bb457afd23a5638697867a192b9a5cb37c430963
|
|
| MD5 |
788071ffca91caef9d162eb51a2e9536
|
|
| BLAKE2b-256 |
93fbc2baf5488a6c821aaf7f9cdeac4ab6a7ab7c9255f7907b4eb8501fb7c6ca
|
File details
Details for the file term_matcher-0.2-py3-none-any.whl.
File metadata
- Download URL: term_matcher-0.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91652425dfcca3a87a5a2c3eee02352788ee9c442d7f7171a5484413e68fc582
|
|
| MD5 |
2ae898d06efcecd7c9ed6a8c0eac4c33
|
|
| BLAKE2b-256 |
78f42eb492776eb6bdb76c7a76f92e2ca39a2e548fe5bdaebaa465a597b865c4
|