#extraction #nlp #text #drug


A core library for extracting drugs from text records

3 releases

Uses new Rust 2021

0.1.2 Aug 2, 2022
0.1.1 Jun 6, 2022
0.1.0 Apr 26, 2022

#99 in Parser tooling

Download history 33/week @ 2022-04-25 9/week @ 2022-05-02 4/week @ 2022-05-09 19/week @ 2022-05-16 8/week @ 2022-05-23 8/week @ 2022-05-30 35/week @ 2022-06-06 4/week @ 2022-06-13 12/week @ 2022-06-20 5/week @ 2022-06-27 2/week @ 2022-07-04 7/week @ 2022-07-11 5/week @ 2022-07-18 8/week @ 2022-07-25 46/week @ 2022-08-01

66 downloads per month
Used in drug-extraction-cli

MIT license

575 lines

Drug Extraction Core

This is the core library used by the CLI and Web application interfaces.

As noted in the main ToolBox documentation, this library's development will be driven heavily by the needs of the CLI application.

Full API documentation can be found on docs.rs.


Drugs, as defined by the Drug type include a name, rx_cui, rx_class_id, and rx_class_relasource. Technically these could be manually compiled, but we recommend fetching from the RxClass API.

For an example, see fetch_drugs() from the CLI application.


  • cargo package manager (rust toolchain)
  • just (optional dev-dependency if you clone this repo)


Cargo is available as a part of the Rust toolchain and is readily available via curl + sh combo (see here).

To install the drug-extraction-core library, simply:

drug-extraction-core = 0.1.0

inside your Cargo.toml.


A simple usage example:

let search = DrugSearch::new(
    &["hello", "world"]
let results = search.scan("hello world", None);
println!("{:?}", results);

We support both CSV and JSONL output.

Example Workflow

For analytical purposes, I would suggest combining all of these jsonlines files into one larger file and then you can process it with a tool like jq or Python - Pandas depending on your use case. 🙂


If you encounter any issues or need support please either contact @nanthony007 or open an issue.


Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for more details. 😃

MIT License



~52K SLoC