Procedure Text Matcher

Description

This is a TextMatcher model that identifies medical procedure entities in clinical text. It recognizes procedures including colonoscopy, biopsy, MRI, CT scan, echocardiogram, endoscopy, blood transfusion, and more.

Predicted Entities

PROCEDURE

Copy S3 URI

How to use


document_assembler = DocumentAssembler()\
    .setInputCol("text")\
    .setOutputCol("document")

sentence_detector = SentenceDetector()\
    .setInputCols(["document"])\
    .setOutputCol("sentence")

tokenizer = Tokenizer()\
    .setInputCols(["sentence"])\
    .setOutputCol("token")

procedure_matcher = TextMatcherInternalModel.pretrained("procedure_matcher", "en", "clinical/models")\
    .setInputCols(["sentence", "token"])\
    .setOutputCol("matched_procedure")

pipeline = Pipeline().setStages([
    document_assembler,
    sentence_detector,
    tokenizer,
    procedure_matcher
])

text = """The patient presented with gastrointestinal symptoms. A colonoscopy was performed which revealed a suspicious lesion, and a biopsy was obtained for pathological examination."""

data = spark.createDataFrame([[text]]).toDF("text")

result = pipeline.fit(data).transform(data)


document_assembler = nlp.DocumentAssembler()\
    .setInputCol("text")\
    .setOutputCol("document")

sentence_detector = nlp.SentenceDetector()\
    .setInputCols(["document"])\
    .setOutputCol("sentence")

tokenizer = nlp.Tokenizer()\
    .setInputCols(["sentence"])\
    .setOutputCol("token")

procedure_matcher = medical.TextMatcherModel.pretrained("procedure_matcher", "en", "clinical/models")\
    .setInputCols(["sentence", "token"])\
    .setOutputCol("matched_procedure")

pipeline = nlp.Pipeline().setStages([
    document_assembler,
    sentence_detector,
    tokenizer,
    procedure_matcher
])

text = """The patient presented with gastrointestinal symptoms. A colonoscopy was performed which revealed a suspicious lesion, and a biopsy was obtained for pathological examination."""

data = spark.createDataFrame([[text]]).toDF("text")

result = pipeline.fit(data).transform(data)


val documentAssembler = new DocumentAssembler()
    .setInputCol("text")
    .setOutputCol("document")

val sentenceDetector = new SentenceDetector()
    .setInputCols(Array("document"))
    .setOutputCol("sentence")

val tokenizer = new Tokenizer()
    .setInputCols(Array("sentence"))
    .setOutputCol("token")

val procedureMatcher = TextMatcherInternalModel.pretrained("procedure_matcher", "en", "clinical/models")
    .setInputCols(Array("sentence", "token"))
    .setOutputCol("matched_procedure")

val pipeline = new Pipeline().setStages(Array(
    documentAssembler,
    sentenceDetector,
    tokenizer,
    procedureMatcher
))

val data = Seq("""The patient presented with gastrointestinal symptoms. A colonoscopy was performed which revealed a suspicious lesion, and a biopsy was obtained for pathological examination.""").toDF("text")

val result = pipeline.fit(data).transform(data)

Results


+-----------+-----+---+---------+
|chunk      |begin|end|label    |
+-----------+-----+---+---------+
|colonoscopy|54   |64 |PROCEDURE|
|biopsy     |113  |118|PROCEDURE|
+-----------+-----+---+---------+

Model Information

Model Name: procedure_matcher
Compatibility: Healthcare NLP 6.2.0+
License: Licensed
Edition: Official
Input Labels: [sentence, token]
Output Labels: [matched_procedure]
Language: en
Size: 972.9 KB
Case sensitive: false