Description
This model extracts countries in clinical notes using rule-based TextMatcherInternal annotator.
Predicted Entities
COUNTRY
How to use
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
.setOutputCol("document")
tokenizer = Tokenizer()\
.setInputCols(["document"])\
.setOutputCol("token")
text_matcher = TextMatcherInternalModel.pretrained("country_matcher","en","clinical/models") \
.setInputCols(["document", "token"])\
.setOutputCol("country")\
.setMergeOverlapping(True)
mathcer_pipeline = Pipeline().setStages([
documentAssembler,
tokenizer,
text_matcher])
data = spark.createDataFrame([["""Côte d’Ivoire
São Tomé & Príncipe
Åland Islands
This is Bahamas and the USAID in the USA here
Name: Johnson, Alice, Record date: 2093-03-22, MR: 846275.
Dr. Emily Brown, IP 192.168.1.1.
She is a 55-year-old female who was admitted to the Global Hospital for hip replacement on 03/22/93.
Patient's VIN: 2HGFA165X8H123456, SSN: 444-55-8888, Driver's license no: C789012D.
Phone: (212) 555-7890, 4321 Oak Street, New York, USA, E-MAIL: alice.johnson@example.com.
Patient has traveled to Japan, France, and Australia in the past year."""]]).toDF("text")
result = mathcer_pipeline.fit(data).transform(data)
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val tokenizer = new Tokenizer()
.setInputCols(Array("document"))
.setOutputCol("token")
val text_matcher = TextMatcherInternalModel.pretrained("country_matcher","en","clinical/models")
.setInputCols(Array("document","token"))
.setOutputCol("country")
.setMergeOverlapping(true)
val matcher_pipeline = new Pipeline().setStages(Array(
documentAssembler,
tokenizer,
text_matcher))
val data = Seq("""Côte d’Ivoire
São Tomé & Príncipe
Åland Islands
This is Bahamas and the USAID in the USA here
Name: Johnson, Alice, Record date: 2093-03-22, MR: 846275.
Dr. Emily Brown, IP 192.168.1.1.
She is a 55-year-old female who was admitted to the Global Hospital for hip replacement on 03/22/93.
Patient's VIN: 2HGFA165X8H123456, SSN: 444-55-8888, Driver's license no: C789012D.
Phone: (212) 555-7890, 4321 Oak Street, New York, USA, E-MAIL: alice.johnson@example.com.
Patient has traveled to Japan, France, and Australia in the past year.""").toDF("text")
val result = matcher_pipeline.fit(data).transform(data)
Results
+-------------------+-----+---+-------+
|chunk |begin|end|label |
+-------------------+-----+---+-------+
|Côte d’Ivoire |0 |12 |Country|
|São Tomé & Príncipe|14 |32 |Country|
|Åland Islands |34 |46 |Country|
|Bahamas |56 |62 |Country|
|USA |85 |87 |Country|
|USA |420 |422|Country|
|Japan |484 |488|Country|
|France |491 |496|Country|
|Australia |503 |511|Country|
+-------------------+-----+---+-------+
Model Information
Model Name: | country_matcher |
Compatibility: | Healthcare NLP 5.5.0+ |
License: | Licensed |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [country] |
Language: | en |
Size: | 10.4 KB |
Case sensitive: | false |