I am using QuickUMLS to extract UMLS Concept Unique Identifiers (CUIs) from text, but no matter what word I input, it always returns "UNK". Here is my code:
from quickumls import QuickUMLS
quickumls_fp = "med7_en/lib/python3.10/site-packages/quickumls"
matcher = QuickUMLS(quickumls_fp)
def extract_umls_cuis(text):
"""Extract UMLS CUIs using QuickUMLS."""
if isinstance(text, str):
matches = matcher.match(text)
if matches:
return [match['cui'] for match in matches[0]]
else:
return "UNK"
sample_text = "diclofenac."
print(extract_umls_cuis(sample_text))
What I Have Checked:
- QuickUMLS Installation: I have installed QuickUMLS correctly.
- UMLS Data Availability: I have set the correct path to QuickUMLS.
- Different Input Words: I tried various medical terms, but all return "UNK".
I am using QuickUMLS to extract UMLS Concept Unique Identifiers (CUIs) from text, but no matter what word I input, it always returns "UNK". Here is my code:
from quickumls import QuickUMLS
quickumls_fp = "med7_en/lib/python3.10/site-packages/quickumls"
matcher = QuickUMLS(quickumls_fp)
def extract_umls_cuis(text):
"""Extract UMLS CUIs using QuickUMLS."""
if isinstance(text, str):
matches = matcher.match(text)
if matches:
return [match['cui'] for match in matches[0]]
else:
return "UNK"
sample_text = "diclofenac."
print(extract_umls_cuis(sample_text))
What I Have Checked:
- QuickUMLS Installation: I have installed QuickUMLS correctly.
- UMLS Data Availability: I have set the correct path to QuickUMLS.
- Different Input Words: I tried various medical terms, but all return "UNK".
- Please correctly format your code – Starship Commented Feb 3 at 1:27
1 Answer
Reset to default 2QuickUMLS setup isn't finding the UMLS data correctly, leading to the "UNK" response.
You can try to test Different Inputs. Try common medical terms like "aspirin"
or "heart attack"
to see if they return valid CUIs, confirming the data is correctly linked.
Additionally, ensure that your quickumls_fp points to the actual data directory, not just the Python package location. The data directory should have subfolders like CDB
, json_db
, or sqlite_db
.