学习健康系统的Python库
项目描述
medkit
CI | |
包 | |
项目 |
medkit
是由HeKA研究团队开发的学习健康系统工具包。
此Python库旨在
-
简化对各种模态(例如,结构化、文本、音频数据)的医疗保健数据的操作,以提取相关特征。
-
从这些不同模态开发监督模型,以支持医疗保健决策。
安装
安装具有基本功能的medkit
pip install medkit-lib
安装包含所有可选功能的medkit
pip install 'medkit-lib[all]'
示例
使用medkit
的基本命名实体识别流水线
# 1. Define individual operations.
from medkit.text.preprocessing import CharReplacer, LIGATURE_RULES, SIGN_RULES
from medkit.text.segmentation import SentenceTokenizer, SyntagmaTokenizer
from medkit.text.context.negation_detector import NegationDetector
from medkit.text.ner.hf_entity_matcher import HFEntityMatcher
# Preprocessing
char_replacer = CharReplacer(rules=LIGATURE_RULES + SIGN_RULES)
# Segmentation
sent_tokenizer = SentenceTokenizer(output_label="sentence")
synt_tokenizer = SyntagmaTokenizer(output_label="syntagma")
# Negation detection
neg_detector = NegationDetector(output_label="is_negated")
# Entity recognition
entity_matcher = HFEntityMatcher(model="my-BERT-model", attrs_to_copy=["is_negated"])
# 2. Combine operations into a pipeline.
from medkit.core.pipeline import Pipeline, PipelineStep
ner_pipeline = Pipeline(
input_keys=["full_text"],
output_keys=["entities"],
steps=[
PipelineStep(char_replacer, input_keys=["full_text"], output_keys=["clean_text"]),
PipelineStep(sent_tokenizer, input_keys=["clean_text"], output_keys=["sentences"]),
PipelineStep(synt_tokenizer, input_keys=["sentences"], output_keys=["syntagmas"]),
PipelineStep(neg_detector, input_keys=["syntagmas"], output_keys=[]),
PipelineStep(entity_matcher, input_keys=["syntagmas"], output_keys=["entities"]),
],
)
# 3. Run the NER pipeline on a BRAT document.
from medkit.io import BratInputConverter
docs = BratInputConverter().load(path="/path/to/dataset/")
entities = ner_pipeline.run([doc.raw_segment for doc in docs])
入门
要开始使用medkit
,请查阅我们的文档。
此文档还包含教程和示例,展示了如何使用medkit
进行不同任务。
贡献
感谢您对medkit的兴趣!
我们很高兴接受您的反馈!
如果您的问题尚未被其他用户报告,请打开一个问题,无论是用于
- 报告错误,
- 讨论代码的当前状态,
- 提交修复,
- 提出新功能,
- 或为文档做出贡献...
如果您想提出一个pull request,可以阅读CONTRIBUTING.md。
联系方式
请通过发送电子邮件到medkit-maintainers@inria.fr联系我们。
项目详情
下载文件
下载您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
medkit_lib-0.16.0.tar.gz (681.2 kB 查看哈希值)
构建分布
medkit_lib-0.16.0-py3-none-any.whl (286.0 kB 查看哈希值)