python - QuickUMLS Always Returns "UNK" for Any Input Text - Stack Overflow

admin2025-04-16  3

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".
Share Improve this question edited Feb 3 at 10:34 desertnaut 60.5k32 gold badges155 silver badges182 bronze badges asked Feb 2 at 14:12 mubashir alimubashir ali 1 1
  • Please correctly format your code – Starship Remembers Shadow Commented Feb 3 at 1:27
Add a comment  | 

1 Answer 1

Reset to default 1

QuickUMLS 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.

转载请注明原文地址:http://anycun.com/QandA/1744798292a87768.html