SSN Number Contextual Parser Model

Description

This model, extracts SSN number 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")

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

ssn_contextual_parser = ContextualParserModel.pretrained("ssn_parser","en","clinical/models") \
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("chunk_ssn") 

chunk_converter = ChunkConverter() \
    .setInputCols(["chunk_ssn"]) \
    .setOutputCol("ner_chunk")

parserPipeline = Pipeline(stages=[
        document_assembler,
        sentence_detector,
        tokenizer,
        ssn_contextual_parser,
        chunk_converter
        ])

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

sample_text = """San Diego, CA, USA
Email: medunites@firsthospital.com
Patient John Davies, 62 y.o. ssn: 023-92-7136 was discharged after 12 hours of monitoring without any signs of internal damage.
TSICU Admission 65332 on 24/06/2019 by ambulance VIN 4Y1SL65848Z411439"""

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 tokenizer = new Tokenizer()
    .setInputCols("sentence")
    .setOutputCol("token")

val ssn_contextual_parser = ContextualParserModel.pretrained("ssn_parser","en","clinical/models")
    .setInputCols(Array("sentence", "token"))
    .setOutputCol("chunk_ssn") 

val chunk_converter = new ChunkConverter()
    .setInputCols("chunk_ssn")
    .setOutputCol("ner_chunk")

val parserPipeline = new Pipeline().setStages(Array(
        document_assembler,
        sentence_detector,
        tokenizer,
        ssn_contextual_parser,
        chunk_converter
))


val sample_text = """San Diego, CA, USA
Email: medunites@firsthospital.com
Patient John Davies, 62 y.o. ssn: 023-92-7136 was discharged after 12 hours of monitoring without any signs of internal damage.
TSICU Admission 65332 on 24/06/2019 by ambulance VIN 4Y1SL65848Z411439"""

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

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

Results


+-----------+-----+---+-----+
|      chunk|begin|end|label|
+-----------+-----+---+-----+
|023-92-7136|   88| 98|  SSN|
+-----------+-----+---+-----+

Model Information

Model Name: ssn_parser
Compatibility: Healthcare NLP 5.5.0+
License: Licensed
Edition: Official
Input Labels: [sentence, token]
Output Labels: [entity_ssn]
Language: en
Size: 9.3 KB
Case sensitive: false