Description
This model extracts medication entities in clinical notes using rule-based TextMatcherInternal
annotator.
Predicted Entities
DRUG
How to use
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
.setOutputCol("document")
tokenizer = Tokenizer()\
.setInputCols(["document"])\
.setOutputCol("token")
text_matcher = TextMatcherInternalModel.pretrained("drug_matcher","en","clinical/models") \
.setInputCols(["document", "token"])\
.setOutputCol("matched_text")\
.setCaseSensitive(False)\
.setDelimiter("#")
mathcer_pipeline = Pipeline().setStages([
documentAssembler,
tokenizer,
text_matcher])
data = spark.createDataFrame([["John's doctor prescribed aspirin for his heart condition, along with paracetamol for his fever and headache, amoxicillin for his tonsilitis and lansoprazole for his GORD on 2023-12-01."]]).toDF("text")
matcher_model = mathcer_pipeline.fit(data)
result = matcher_model.transform(data)
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val tokenizer = new Tokenizer()
.setInputCols(Array("document"))
.setOutputCol("token")
val text_matcher = TextMatcherInternalModel.pretrained("drug_matcher","en","clinical/models")
.setInputCols(Array("document","token"))
.setOutputCol("matched_text")
val mathcer_pipeline = new Pipeline()
.setStages(Array( documentAssembler,
tokenizer,
text_matcher))
val data = Seq("John's doctor prescribed aspirin for his heart condition, along with paracetamol for his fever and headache, amoxicillin for his tonsilitis and lansoprazole for his GORD on 2023-12-01.") .toDF("text")
val matcher_model = mathcer_pipeline.fit(data)
val result = matcher_model.transform(data)
Results
+------------+-----+---+-----+
| chunk|begin|end|label|
+------------+-----+---+-----+
| aspirin| 25| 31| DRUG|
| paracetamol| 69| 79| DRUG|
| amoxicillin| 109|119| DRUG|
|lansoprazole| 144|155| DRUG|
+------------+-----+---+-----+
Model Information
Model Name: | drug_matcher |
Compatibility: | Healthcare NLP 5.3.0+ |
License: | Licensed |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [matched_text] |
Language: | en |
Size: | 3.7 MB |
Case sensitive: | false |