Skip to main content

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_extraction for obtaining the term_to_code.json. This step can be replaced for any other dictionaries.
  • Run demo.py for 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

  1. Synonyms
  2. Multi-term matching
  3. ElasticSearch for bigger size dictionaries (basically full Athena Concepts).

Installation as package

pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

term_matcher-0.21.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

term_matcher-0.21-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file term_matcher-0.21.tar.gz.

File metadata

  • Download URL: term_matcher-0.21.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

Hashes for term_matcher-0.21.tar.gz
Algorithm Hash digest
SHA256 b1aec28cfa1d49b714bf9f202787026138a6766bd8068fefeb520379a3a08c1c
MD5 59944fd7ad90230d20ecbd2587539053
BLAKE2b-256 45b1c83f81d96f9604feb95049d53b95d07c3a43fab9d297dba53f6551a5a2c9

See more details on using hashes here.

File details

Details for the file term_matcher-0.21-py3-none-any.whl.

File metadata

  • Download URL: term_matcher-0.21-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

Hashes for term_matcher-0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 a57c9ef92401b3c09f36ab703fed5862f5d083a5214a4aaa1f6bbbf6cf78db7d
MD5 2192f8d8d6bd3ddce22d8bc41e2a8a56
BLAKE2b-256 9f033b4b462b23262202682955f9e17e211867471defe5a0054fcaa73ef8cc4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page