PHEE Query Skill
Search PHEE annotated pharmacovigilance events by drug name, adverse effect,
or free text. Substring matching is case-insensitive across all event fields.
| Input Pattern |
Match Logic |
drug name (e.g. phenytoin) |
substring on drug, treatment, combination_drug, and text |
adverse effect (e.g. hepatotoxicity) |
substring on effect, treatment_disorder, and text |
| any other text |
substring on all event fields and full sentence |
API
| Function |
Input |
Returns |
load_phee(data_dir) |
directory path |
list[dict] (cached) |
search(records, entity) |
single entity string |
list[dict] |
search_batch(records, entities) |
list of entity strings |
dict[str, list[dict]] |
summarize(hits, entity) |
hit list + label |
compact text (sentence count, ADE/PTE counts, top drugs & effects) |
to_json(hits) |
hit list |
list[dict] |
Record Schema
Each record returned by search:
{
"id": "8908396_3",
"text": "A 52-year-old Black woman on phenytoin therapy ...",
"split": "train",
"events": [
{
"event_type": "Adverse_event | Potential_therapeutic_event",
"trigger": ["developed"],
"subject": ["A 52-year-old Black woman ..."],
"subject_age": ["52-year-old"],
"subject_gender": ["woman"],
"subject_race": ["Black"],
"subject_population": [],
"subject_disorder": ["post-traumatic epilepsy"],
"treatment": ["phenytoin therapy ..."],
"drug": ["phenytoin"],
"dosage": [],
"freq": [],
"route": [],
"duration": [],
"treatment_disorder": ["post-traumatic epilepsy"],
"combination_drug": [],
"effect": ["transient hemiparesis"]
}
]
}
Usage
See if __name__ == "__main__" block in 38_PHEE.py for runnable examples
covering: single drug search, single effect search, batch search, and JSON
output.
Data
- Source: PHEE dataset (Zenodo record 7689970), EMNLP 2022
- Files:
train.json (2,900 sentences), dev.json (960), test.json (~960)
- Path:
DATA_DIR variable in 38_PHEE.py
(resources_metadata/drug_nlp/PHEE/data/json)
- Event types:
Adverse_event, Potential_therapeutic_event
- Main arguments: Subject, Treatment, Effect
- Sub-arguments: Subject (age, gender, race, population, disorder); Treatment (drug, dosage, freq, route, duration, disorder, combination.drug)
1---2name: phee-query3description: Query the PHEE pharmacovigilance event extraction dataset. Use whenever the user asks about annotated adverse drug events, pharmacovigilance case reports, drug–effect associations from medical literature, or wants to find PHEE examples mentioning a drug name, adverse effect, or condition.4---5
6# PHEE Query Skill
7
8Search PHEE annotated pharmacovigilance events by drug name, adverse effect,
9or free text. Substring matching is case-insensitive across all event fields.
10
11| Input Pattern | Match Logic |
12|---|---|
13| drug name (e.g. `phenytoin`) | substring on `drug`, `treatment`, `combination_drug`, and `text` |
14| adverse effect (e.g. `hepatotoxicity`) | substring on `effect`, `treatment_disorder`, and `text` |
15| any other text | substring on all event fields and full sentence |
16
17## API
18
19| Function | Input | Returns |
20|---|---|---|
21| `load_phee(data_dir)` | directory path | list[dict] (cached) |
22| `search(records, entity)` | single entity string | list[dict] |
23| `search_batch(records, entities)` | list of entity strings | dict[str, list[dict]] |
24| `summarize(hits, entity)` | hit list + label | compact text (sentence count, ADE/PTE counts, top drugs & effects) |
25| `to_json(hits)` | hit list | list[dict] |
26
27## Record Schema
28
29Each record returned by `search`:
30
31```
32{
33 "id": "8908396_3",
34 "text": "A 52-year-old Black woman on phenytoin therapy ...",
35 "split": "train",
36 "events": [
37 {
38 "event_type": "Adverse_event | Potential_therapeutic_event",
39 "trigger": ["developed"],
40 "subject": ["A 52-year-old Black woman ..."],
41 "subject_age": ["52-year-old"],
42 "subject_gender": ["woman"],
43 "subject_race": ["Black"],
44 "subject_population": [],
45 "subject_disorder": ["post-traumatic epilepsy"],
46 "treatment": ["phenytoin therapy ..."],
47 "drug": ["phenytoin"],
48 "dosage": [],
49 "freq": [],
50 "route": [],
51 "duration": [],
52 "treatment_disorder": ["post-traumatic epilepsy"],
53 "combination_drug": [],
54 "effect": ["transient hemiparesis"]
55 }
56 ]
57}
58```
59
60## Usage
61
62See `if __name__ == "__main__"` block in `38_PHEE.py` for runnable examples
63covering: single drug search, single effect search, batch search, and JSON
64output.
65
66## Data
67
68- **Source**: PHEE dataset (Zenodo record 7689970), EMNLP 2022
69- **Files**: `train.json` (~2,900 sentences), `dev.json` (~960), `test.json` (~960)
70- **Path**: `DATA_DIR` variable in `38_PHEE.py`
71 (`resources_metadata/drug_nlp/PHEE/data/json`)
72- **Event types**: `Adverse_event`, `Potential_therapeutic_event`
73- **Main arguments**: Subject, Treatment, Effect
74- **Sub-arguments**: Subject (age, gender, race, population, disorder); Treatment (drug, dosage, freq, route, duration, disorder, combination.drug)