Using LangExtract's medical text processing capabilities can quickly achieve this goal. The specific steps are as follows:
- Prepare prompt words: explicitly specify the fields to be extracted, e.g.
"Extract medication names, dosages, and administration routes from clinical notes." - Input of medical text: clinical notes containing drug information as input
- Call the extraction function:
result = lx.extract(text, prompt=prompt, model="gemini-2.5-pro")(Recommended to use the more performant pro model)
After execution the output will contain structured data such as:{"entity": "Metformin", "dosage": "500 mg", "route": "orally"}. For batch processing, save as a JSONL-formatted file or generate an HTML visualization file for easy viewing.
This answer comes from the articleLangExtract: open source tools to extract structured data from textThe































