最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.4k32 gold badges152 silver badges180 bronze badges asked Feb 2 at 14:12 mubashir alimubashir ali 1 1
  • Please correctly format your code – Starship Commented Feb 3 at 1:27
Add a comment  | 

1 Answer 1

Reset to default 2

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.

发布评论

评论列表(0)

  1. 暂无评论