医学本体识别 映射-UMLS

Dimension scispaCy + UMLS MedCAT
Concept source UMLS UMLS
NER Statistical (fixed) Integrated
Disambiguation String similarity Neural context model
Abbreviations Weak Strong
Domain adaptation ❌ ✅ (trainable)
Transparency High Medium
Speed Fast Moderate
Reproducibility High Medium
Explainability alignment Excellent Moderate
Setup complexity Low High

Code

Clinical sentence

↓

scispaCy NER (en_core_sci_md)

↓

String-based candidate generation

↓

UMLS Metathesaurus lookup

↓

Similarity-based linking (CUI + score)

复制代码
# UMLS concept mapping for a clinical sentence using Python
# This example uses scispaCy + UMLS Entity Linker
import spacy
from scispacy.linking import EntityLinker

# Load a biomedical NLP model
nlp = spacy.load("en_core_sci_md")

# Add UMLS entity linker to the pipeline
# Use "umls" as the linker name and add it with a custom name
nlp.add_pipe("scispacy_linker", config={"resolve_abbreviations": True, "linker_name": "umls"})

# Get reference to the linker component
linker = nlp.get_pipe("scispacy_linker")

# Input sentence
sentence = "he has a family history of seizure and eyes often closed and resistant to passive opening"

# Process the sentence
doc = nlp(sentence)

# Extract and display UMLS concepts
results = []
for ent in doc.ents:
    # Check if the entity has linked concepts
    if ent._.kb_ents:  # Use kb_ents instead of umls_ents
        for umls_ent in ent._.kb_ents:
            cui, score = umls_ent
            concept = linker.kb.cui_to_entity[cui]
            results.append({
                "text_span": ent.text,
                "cui": cui,
                "preferred_name": concept.canonical_name,
                "semantic_types": concept.types,
                "confidence_score": score
            })

# Print results
if results:
    for r in results:
        print(r)
else:
    print("No UMLS concepts found.")

Outcome

{'text_span': 'family history of seizure', 'cui': 'C0241889', 'preferred_name': 'Family history (finding)', 'semantic_types': 'T033', 'confidence_score': 0.8135724663734436}

{'text_span': 'family history of seizure', 'cui': 'C5238701', 'preferred_name': 'Family History of Myocardial Infarction', 'semantic_types': 'T033', 'confidence_score': 0.7316329479217529}

{'text_span': 'family history of seizure', 'cui': 'C2317524', 'preferred_name': 'Family history of coronary arteriosclerosis', 'semantic_types': 'T033', 'confidence_score': 0.7181885242462158}

{'text_span': 'family history of seizure', 'cui': 'C0260515', 'preferred_name': 'Family history of cancer', 'semantic_types': 'T033', 'confidence_score': 0.7104339003562927}

{'text_span': 'eyes', 'cui': 'C0015392', 'preferred_name': 'Eye', 'semantic_types': 'T023', 'confidence_score': 0.9724115133285522}

{'text_span': 'eyes', 'cui': 'C0235267', 'preferred_name': 'Redness of eye', 'semantic_types': 'T184', 'confidence_score': 0.8306822180747986}

{'text_span': 'eyes', 'cui': 'C0266574', 'preferred_name': 'Ablepharon', 'semantic_types': 'T019', 'confidence_score': 0.7846059799194336}

{'text_span': 'eyes', 'cui': 'C0885957', 'preferred_name': 'Eye care (regime/therapy)', 'semantic_types': 'T058', 'confidence_score': 0.783681333065033}

{'text_span': 'eyes', 'cui': 'C1268161', 'preferred_name': 'Eye part', 'semantic_types': 'T023', 'confidence_score': 0.7718889713287354}

{'text_span': 'closed', 'cui': 'C0587267', 'preferred_name': 'Closed', 'semantic_types': 'T169', 'confidence_score': 0.9921370148658752}

{'text_span': 'closed', 'cui': 'C1548219', 'preferred_name': 'Bed Status - Closed', 'semantic_types': 'T078', 'confidence_score': 0.9921370148658752}

{'text_span': 'closed', 'cui': 'C5669719', 'preferred_name': 'Closed Captioning', 'semantic_types': 'T170', 'confidence_score': 0.709942638874054}

{'text_span': 'resistant', 'cui': 'C0332325', 'preferred_name': 'Resistant (qualifier value)', 'semantic_types': 'T169', 'confidence_score': 0.9936941862106323}

{'text_span': 'resistant', 'cui': 'C1550464', 'preferred_name': 'resistant - Observation Interpretation Susceptibility', 'semantic_types': 'T078', 'confidence_score': 0.9936941862106323}

{'text_span': 'resistant', 'cui': 'C2827757', 'preferred_name': 'Antimicrobial Resistance Result', 'semantic_types': 'T034', 'confidence_score': 0.9936941862106323}

{'text_span': 'resistant', 'cui': 'C2986418', 'preferred_name': 'Resistant Starch', 'semantic_types': 'T109', 'T121', 'confidence_score': 0.7441271543502808}

{'text_span': 'resistant', 'cui': 'C1514892', 'preferred_name': 'Resistance Process', 'semantic_types': 'T039', 'confidence_score': 0.7311867475509644}

{'text_span': 'passive opening', 'cui': 'C0175566', 'preferred_name': 'Open', 'semantic_types': 'T082', 'confidence_score': 0.7032682299613953}

{'text_span': 'passive opening', 'cui': 'C1882151', 'preferred_name': 'Opening', 'semantic_types': 'T082', 'confidence_score': 0.7032682299613953}

相关推荐
Дерек的学习记录18 分钟前
Unreal Engine 5:第三人称运动系统和人物动画
开发语言·学习·ue5
用户03321266636739 分钟前
使用 Python 在 Excel 中添加与删除筛选器
python·excel
Ramble_Naylor41 分钟前
Rust深度解读:异步流(Async Streams)与生成器的处理艺术
开发语言·后端·rust
1M5543 分钟前
AI应用后端工程(03):回答输出一半就断了:AI 流式接口如何定义成功与失败?
python·面试·职场和发展·计算机专业·agent开发
努力实干1 小时前
简单工厂模式(Simple Factory Pattern)——C++
开发语言·c++·简单工厂模式
熊猫钓鱼>_>1 小时前
平行视界兼容模式与魔法变量配置避坑【鸿蒙心迹】
运维·服务器·开发语言·笔记·华为·harmonyos·openharmony
大鹏说大话1 小时前
PHP 大文件上传解决方案:分片上传完整思路
开发语言·php
AI 编程助手GPT2 小时前
GPT 排的日志时间线差一小时?用 zoneinfo 复现夏令时回拨
人工智能·python·gpt
Thanks_ks2 小时前
【第 003 讲】全面认识 Python:语言起源与设计哲学 | 行业地位与流行趋势 | 技术优势与应用领域 | 技术边界与工程局限
人工智能·python·数据分析·编程语言·python 入门·web 开发·python 之禅
Wang's Blog2 小时前
Java 项目实战:交友项目 - 我的访客:需求说明
java·开发语言·交友