Date Regex Matcher

Description

This model, extracts date entities from clinical texts.

Copy S3 URI

How to use


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

sentence_detector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare","en","clinical/models")\
    .setInputCols(["document"])\
    .setOutputCol("sentence")

date_regex_matcher = RegexMatcherInternalModel.pretrained("date_matcher","en","clinical/models") \
    .setInputCols(["sentence"]) \
    .setOutputCol("date_parser")

parserPipeline = Pipeline(stages=[
        document_assembler,
        sentence_detector,
        date_regex_matcher
        ])

model = parserPipeline.fit(spark.createDataFrame([[""]]).toDF("text"))

sample_text = """Name : Hendrickson, Ora, Record date: 2093-01-13, # 719435.
Dr. John Green, ID: 1231511863, IP 203.120.223.13.
He is a 60-year-old male was admitted to the Day Hospital for cystectomy on 01/13/93.
Patient's VIN : 1HGBH41JXMN109286, VIN 4Y1SL65848Z411439, VIN 1HGCM82633A123456 - VIN JH4KA7560MC012345 - VIN 5YJSA1E14HF123456
SSN #333-44-6666, Driver's license no: A334455B, plate 34NLP34. Lic: 12345As. Cert: 12345As
Phone (302) 786-5227, 0295 Keats Street, San Francisco, E-MAIL: smith@gmail.com"""

result = model.transform(spark.createDataFrame([[sample_text]]).toDF("text"))


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

val sentence_detector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare","en","clinical/models")
    .setInputCols("document")
    .setOutputCol("sentence")

val date_regex_matcher = RegexMatcherInternalModel.pretrained("date_matcher","en","clinical/models")
    .setInputCols("sentence")
    .setOutputCol("date_parser")

val parserPipeline = new Pipeline().setStages(Array(
        document_assembler,
        sentence_detector,
        date_regex_matcher
))


val sample_text = """Name : Hendrickson, Ora, Record date: 2093-01-13, # 719435.
Dr. John Green, ID: 1231511863, IP 203.120.223.13.
He is a 60-year-old male was admitted to the Day Hospital for cystectomy on 01/13/93.
Patient's VIN : 1HGBH41JXMN109286, VIN 4Y1SL65848Z411439, VIN 1HGCM82633A123456 - VIN JH4KA7560MC012345 - VIN 5YJSA1E14HF123456
SSN #333-44-6666, Driver's license no: A334455B, plate 34NLP34. Lic: 12345As. Cert: 12345As
Phone (302) 786-5227, 0295 Keats Street, San Francisco, E-MAIL: smith@gmail.com"""

val data = Seq(sample_text).toDF("text")

val results = parserPipeline.fit(data).transform(data)

Results


+----------+-----+---+-----+
|     chunk|begin|end|label|
+----------+-----+---+-----+
|2093-01-13|   38| 47| DATE|
|  01/13/93|  187|194| DATE|
|33-44-6666|  331|340| DATE|
+----------+-----+---+-----+

Model Information

Model Name: date_matcher
Compatibility: Healthcare NLP 5.5.0+
License: Licensed
Edition: Official
Input Labels: [sentence]
Output Labels: [entity_date]
Language: en
Size: 5.2 KB