简介
NLM Medical Text Indexer (MTI),医学文本索引,顾名思义,作用是输入一段医学文本,输出相应的关键字。官网链接https://ii.nlm.nih.gov/MTI/。
如何使用MTI
MTI提供三种使用方式:
- MeSH on Demand
链接 https://meshb.nlm.nih.gov/MeSHonDemand,使用方式很简单,复制一段文本,关键词会高亮显示,截张图。
- Batch-Mode (Requires UTS Account)
需要账号,目前我还在申请阶段,进不去。 - Download our Web API (Requires UTS Account)
使用官方提供的API接口,这是很实用的一种方法。web api使用介绍
Web API 教程
解压jar包,即工程文件
Windows: winzip, pkzip, or zip解压就行
Unix、Linux、Mac
$ java sun.tools.jar.Main xf SKR_Web_API_V2_3.jar
- 打开工程文件,examples目录下几个java文件,新建一个Test.java, 代码如下. 注意用户名、密码、邮箱、txt文件的绝对路径。
关键部分代码
Test.java
import gov.nih.nlm.nls.skr.GenericObject;
public class Test {
public static void main(String[] args) {
GenericObject myGenericObj = new GenericObject("你的用户名", "你的密码");
myGenericObj.setField("Email_Address", "你的邮箱");
myGenericObj.setFileField("UpLoad_File", "/Users/wanglei/Downloads/CXR1.txt"); # 注意是绝对路径,相对路径出错
myGenericObj.setField("Batch_Command", "MTI -opt1L_DCMS -E");
myGenericObj.setField("BatchNotes", "SKR Web API test");
myGenericObj.setField("SilentEmail", true);
try
{
String results = myGenericObj.handleSubmission();
System.out.print(results);
} catch (RuntimeException ex) {
System.err.println("");
System.err.print("An ERROR has occurred while processing your");
System.err.println(" request, please review any");
System.err.print("lines beginning with \"Error:\" above and the");
System.err.println(" trace below for indications of");
System.err.println("what may have gone wrong.");
System.err.println("");
System.err.println("Trace:");
ex.printStackTrace();
} // catch
}
}
结果展示
医学文本CXR1.txt
Normal chest x-XXXX.The cardiac silhouette and mediastinum size are within normal limits. There is no pulmonary edema. There is no focal consolidation. There are no XXXX of a pleural effusion. There is no evidence of pneumothorax.
得到的results
结束语
如果需要批量处理医学文本得到相应的标签、关键字,需要使用官方提供API接口,自己写代码。
注意代码中txt文件填写绝对路径,我原本照着官网给的相对路径会报找不到文件的错。
附上我的项目链接:
https://github.com/wangleihitcs/MTI