$npx -y skills add QSong-github/DrugClaw --skill ddi_corpus| Field | Value | |-------|-------| | Resource | DDI Corpus 2013 | | Category | Drug-centric / Drug NLP & Text Mining | | Source | GitHub | | Paper | [Herrero-Zazo et al., 2013](https://www.sciencedirect.com/science/article/
| 1 | # DDI Corpus 2013 – Drug-Drug Interaction Query Skill |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | | Field | Value | |
| 6 | |-------|-------| |
| 7 | | **Resource** | DDI Corpus 2013 | |
| 8 | | **Category** | Drug-centric / Drug NLP & Text Mining | |
| 9 | | **Source** | [GitHub](https://github.com/isegura/DDICorpus) | |
| 10 | | **Paper** | [Herrero-Zazo et al., 2013](https://www.sciencedirect.com/science/article/pii/S1532046413001123) | |
| 11 | | **Corpus Size** | ~2,740 unique entities, ~5,000 annotated DDI pairs | |
| 12 | | **Sources** | DrugBank descriptions + MEDLINE abstracts | |
| 13 | |
| 14 | The DDI Corpus 2013 is the standard benchmark for drug-drug interaction (DDI) extraction from biomedical text. Each XML file contains sentences with annotated drug entities and pairwise DDI labels. |
| 15 | |
| 16 | **DDI Types:** |
| 17 | - `mechanism` – pharmacokinetic mechanism described (e.g., altered absorption/metabolism) |
| 18 | - `effect` – clinical effect of the interaction (e.g., increased bleeding risk) |
| 19 | - `advise` – recommendation or warning about co-administration |
| 20 | - `int` – stated interaction without further detail |
| 21 | |
| 22 | **Entity Types:** `drug`, `group`, `brand`, `drug_n` (active substance not approved for human use) |
| 23 | |
| 24 | ## Setup |
| 25 | |
| 26 | **1. Download & extract** (one-time): |
| 27 | |
| 28 | ```bash |
| 29 | git clone https://github.com/isegura/DDICorpus.git |
| 30 | cd DDICorpus |
| 31 | unzip DDICorpus-2013.zip |
| 32 | ``` |
| 33 | |
| 34 | **2. Set the corpus path** in `30_DDI_Corpus_2013.py`: |
| 35 | |
| 36 | ```python |
| 37 | CORPUS_ROOT = "/path/to/DDICorpus-master" # contains DDICorpus/Train/ and DDICorpus/Test/ |
| 38 | ``` |
| 39 | |
| 40 | Or pass `--root` at runtime or set env var `DDI_CORPUS_ROOT`. |
| 41 | |
| 42 | ## Usage |
| 43 | |
| 44 | ### Python API |
| 45 | |
| 46 | ```python |
| 47 | from 30_DDI_Corpus_2013 import query_entities, list_all_entities, corpus_stats |
| 48 | |
| 49 | # Query a single drug |
| 50 | result = query_entities("aspirin") |
| 51 | |
| 52 | # Query multiple drugs at once |
| 53 | result = query_entities(["warfarin", "metformin", "digoxin"]) |
| 54 | |
| 55 | # List all entity names in the corpus |
| 56 | names = list_all_entities() |
| 57 | |
| 58 | # Get corpus-level statistics |
| 59 | stats = corpus_stats() |
| 60 | ``` |
| 61 | |
| 62 | ### CLI (直接运行) |
| 63 | |
| 64 | ```bash |
| 65 | python 30_DDI_Corpus_2013.py |
| 66 | ``` |
| 67 | |
| 68 | 直接运行即输出 demo 结果(corpus 统计 → 单实体查询 → 批量查询 → 未找到示例)。 |
| 69 | 修改 `__main__` 块中的实体名即可自定义查询。 |
| 70 | |
| 71 | ## Output Format |
| 72 | |
| 73 | `query_entities` returns a JSON string. Each element: |
| 74 | |
| 75 | ```json |
| 76 | { |
| 77 | "query": "aspirin", |
| 78 | "found": true, |
| 79 | "canonical_names": ["ASPIRIN", "Aspirin", "aspirin"], |
| 80 | "entity_types": ["brand", "drug"], |
| 81 | "total_interactions": 65, |
| 82 | "interactions": [ |
| 83 | { |
| 84 | "partner": "ketoprofen", |
| 85 | "ddi_type": "mechanism", |
| 86 | "sentence": "concurrent administration of aspirin decreased ketoprofen protein binding...", |
| 87 | "source": "Train/DrugBank" |
| 88 | } |
| 89 | ], |
| 90 | "example_sentences": ["..."] |
| 91 | } |
| 92 | ``` |
| 93 | |
| 94 | If an entity is not found: `{"query": "xyz", "found": false}`. |
| 95 | |
| 96 | ## Parameters |
| 97 | |
| 98 | | Parameter | Default | Description | |
| 99 | |-----------|---------|-------------| |
| 100 | | `entities` | *(required)* | `str` or `list[str]` — drug names to look up (case-insensitive) | |
| 101 | | `corpus_root` | `CORPUS_ROOT` | Path to the extracted DDICorpus-master directory | |
| 102 | | `max_interactions` | `20` | Maximum interaction records returned per entity | |
| 103 | | `max_sentences` | `5` | Maximum example sentences returned per entity | |
| 104 | |
| 105 | ## Dependencies |
| 106 | |
| 107 | Python 3.10+ standard library only (`xml.etree.ElementTree`, `json`, `os`, `collections`). No third-party packages required. |